import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
/**
* GDB Tracepoint extension of TmfTrace. This class implements the necessary
org.eclipse.linuxtools.tmf.core.tests.statesystem.AllTests.class,
org.eclipse.linuxtools.tmf.core.tests.statistics.AllTests.class,
org.eclipse.linuxtools.tmf.core.tests.trace.AllTests.class,
+ org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint.AllTests.class,
+ org.eclipse.linuxtools.tmf.core.tests.trace.location.AllTests.class,
org.eclipse.linuxtools.tmf.core.tests.uml2sd.AllTests.class,
org.eclipse.linuxtools.tmf.core.tests.util.AllTests.class
})
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
- TmfCheckpointIndexTest.class,
- TmfCheckpointIndexTest2.class,
- TmfCheckpointTest.class,
TmfContextTest.class,
- TmfExperimentCheckpointIndexTest.class,
TmfExperimentTest.class,
- TmfLocationTest.class,
TmfMultiTraceExperimentTest.class,
TmfTraceManagerTest.class,
TmfTraceTest.class
})
-public class AllTests {
-
-}
\ No newline at end of file
+public class AllTests {}
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Francois Chouinard - Adapted for TMF Trace Model 1.0
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.List;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer;
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfEmptyTraceStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfCheckpointIndexTest class.
- */
-@SuppressWarnings("javadoc")
-public class TmfCheckpointIndexTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private static final String DIRECTORY = "testfiles";
- private static final String TEST_STREAM = "A-Test-10K";
- private static final int BLOCK_SIZE = 100;
- private static final int NB_EVENTS = 10000;
- private static TestTrace fTrace = null;
- private static EmptyTestTrace fEmptyTrace = null;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- setupTrace(DIRECTORY + File.separator + TEST_STREAM);
- }
-
- @After
- public void tearDown() {
- fTrace.dispose();
- fTrace = null;
- fEmptyTrace.dispose();
- fEmptyTrace = null;
- }
-
- // ------------------------------------------------------------------------
- // Helper classes
- // ------------------------------------------------------------------------
-
- private static class TestIndexer extends TmfCheckpointIndexer {
- @SuppressWarnings({ })
- public TestIndexer(TestTrace testTrace) {
- super(testTrace, BLOCK_SIZE);
- }
- @SuppressWarnings({ })
- public TestIndexer(EmptyTestTrace testTrace) {
- super(testTrace, BLOCK_SIZE);
- }
- public List<ITmfCheckpoint> getCheckpoints() {
- return getTraceIndex();
- }
- }
-
- private class TestTrace extends TmfTraceStub {
- public TestTrace(String path, int blockSize) throws TmfTraceException {
- super(path, blockSize);
- setIndexer(new TestIndexer(this));
- }
- @Override
- public TestIndexer getIndexer() {
- return (TestIndexer) super.getIndexer();
- }
- }
-
- private class EmptyTestTrace extends TmfEmptyTraceStub {
- public EmptyTestTrace() {
- super();
- setIndexer(new TestIndexer(this));
- }
- @Override
- public TestIndexer getIndexer() {
- return (TestIndexer) super.getIndexer();
- }
- }
-
- // ------------------------------------------------------------------------
- // Helper functions
- // ------------------------------------------------------------------------
-
- private synchronized void setupTrace(final String path) {
- if (fTrace == null) {
- try {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
- final File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TestTrace(test.toURI().getPath(), BLOCK_SIZE);
- fTrace.indexTrace(true);
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- }
-
- if (fEmptyTrace == null) {
- fEmptyTrace = new EmptyTestTrace();
- fEmptyTrace.indexTrace(true);
- }
- }
-
- // ------------------------------------------------------------------------
- // Verify checkpoints
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfTraceIndexing() {
- assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize());
- assertEquals("getTraceSize", NB_EVENTS, fTrace.getNbEvents());
- assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, fTrace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, fTrace.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, fTrace.getEndTime().getValue());
-
- List<ITmfCheckpoint> checkpoints = fTrace.getIndexer().getCheckpoints();
- int pageSize = fTrace.getCacheSize();
- assertTrue("Checkpoints exist", checkpoints != null);
- assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
-
- // Validate that each checkpoint points to the right event
- for (int i = 0; i < checkpoints.size(); i++) {
- ITmfCheckpoint checkpoint = checkpoints.get(i);
- TmfContext context = new TmfContext(checkpoint.getLocation(), i * pageSize);
- ITmfEvent event = fTrace.parseEvent(context);
- assertTrue(context.getRank() == i * pageSize);
- assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
- }
- }
-
- @Test
- public void testEmptyTmfTraceIndexing() {
- assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, fEmptyTrace.getCacheSize());
- assertEquals("getTraceSize", 0, fEmptyTrace.getNbEvents());
- assertEquals("getRange-start", TmfTimestamp.BIG_BANG, fEmptyTrace.getTimeRange().getStartTime());
- assertEquals("getRange-end", TmfTimestamp.BIG_BANG, fEmptyTrace.getTimeRange().getEndTime());
- assertEquals("getStartTime", TmfTimestamp.BIG_BANG, fEmptyTrace.getStartTime());
- assertEquals("getEndTime", TmfTimestamp.BIG_BANG, fEmptyTrace.getEndTime());
-
- List<ITmfCheckpoint> checkpoints = fEmptyTrace.getIndexer().getCheckpoints();
- int pageSize = fEmptyTrace.getCacheSize();
- assertTrue("Checkpoints exist", checkpoints != null);
- assertEquals("Checkpoints size", 0, checkpoints.size());
-
- // Validate that each checkpoint points to the right event
- for (int i = 0; i < checkpoints.size(); i++) {
- ITmfCheckpoint checkpoint = checkpoints.get(i);
- TmfContext context = new TmfContext(checkpoint.getLocation(), i * pageSize);
- ITmfEvent event = fEmptyTrace.parseEvent(context);
- assertTrue(context.getRank() == i * pageSize);
- assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
- }
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Bernd Hufmann - Initial API and implementation
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.List;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfEmptyTraceStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfCheckpointIndexer class (events with same
- * timestamp around checkpoint).
- */
-@SuppressWarnings("javadoc")
-public class TmfCheckpointIndexTest2 {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private static final String DIRECTORY = "testfiles";
- // Trace has 3 events at t=101 at rank 99, 100, 101
- // Trace has events with same timestamp (ts=102) for ranks 102..702 -> 2 checkpoints with same timestamp are created
- private static final String TEST_STREAM = "A-Test-10K-2";
- private static final int BLOCK_SIZE = 100;
- private static final int NB_EVENTS = 702;
- private static TestTrace fTrace = null;
- private static EmptyTestTrace fEmptyTrace = null;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- setupTrace(DIRECTORY + File.separator + TEST_STREAM);
- }
-
- @After
- public void tearDown() {
- fTrace.dispose();
- fTrace = null;
- fEmptyTrace.dispose();
- fEmptyTrace = null;
- }
-
- // ------------------------------------------------------------------------
- // Helper classes
- // ------------------------------------------------------------------------
-
- private static class TestIndexer extends TmfCheckpointIndexer {
- @SuppressWarnings({ })
- public TestIndexer(TestTrace testTrace) {
- super(testTrace, BLOCK_SIZE);
- }
- @SuppressWarnings({ })
- public TestIndexer(EmptyTestTrace testTrace) {
- super(testTrace, BLOCK_SIZE);
- }
- public List<ITmfCheckpoint> getCheckpoints() {
- return getTraceIndex();
- }
- }
-
- private class TestTrace extends TmfTraceStub {
- public TestTrace(String path, int blockSize) throws TmfTraceException {
- super(path, blockSize);
- setIndexer(new TestIndexer(this));
- }
- @Override
- public TestIndexer getIndexer() {
- return (TestIndexer) super.getIndexer();
- }
- }
-
- private class EmptyTestTrace extends TmfEmptyTraceStub {
- public EmptyTestTrace() {
- super();
- setIndexer(new TestIndexer(this));
- }
- @Override
- public TestIndexer getIndexer() {
- return (TestIndexer) super.getIndexer();
- }
- }
-
- // ------------------------------------------------------------------------
- // Helper functions
- // ------------------------------------------------------------------------
-
- private synchronized void setupTrace(final String path) {
- if (fTrace == null) {
- try {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
- final File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TestTrace(test.toURI().getPath(), BLOCK_SIZE);
- fTrace.indexTrace(true);
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- }
-
- if (fEmptyTrace == null) {
- fEmptyTrace = new EmptyTestTrace();
- fEmptyTrace.indexTrace(true);
- }
- }
-
- // ------------------------------------------------------------------------
- // Verify checkpoints
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfTraceMultiTimestamps() {
- assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize());
- assertEquals("getTraceSize", NB_EVENTS, fTrace.getNbEvents());
- assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", 102, fTrace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, fTrace.getStartTime().getValue());
- assertEquals("getEndTime", 102, fTrace.getEndTime().getValue());
-
- List<ITmfCheckpoint> checkpoints = fTrace.getIndexer().getCheckpoints();
- assertTrue("Checkpoints exist", checkpoints != null);
- assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE + 1, checkpoints.size());
-
- // Trace has 3 events with same timestamp (ts=101) at rank 99, 100, 101
-
- // Verify that the event at rank=99 is returned when seeking to ts=101 (first event with this timestamp)
- // and not the event at checkpoint boundary
- TmfTimestamp seekTs = new TmfTimestamp(101, -3, 0);
- ITmfContext ctx = fTrace.seekEvent(seekTs);
- ITmfEvent event = fTrace.getNext(ctx);
-
- assertEquals(99, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- event = fTrace.getNext(ctx);
-
- assertEquals(100, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- event = fTrace.getNext(ctx);
-
- assertEquals(101, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- // Trace has events with same timestamp (ts=102) for ranks 102..702 -> 2 checkpoints with same timestamp are created
- // Verify that the event at rank=102 is returned when seeking to ts=102 (first event with this timestamp)
- // and not the event at checkpoint boundary
- seekTs = new TmfTimestamp(102, -3, 0);
- ctx = fTrace.seekEvent(seekTs);
- event = fTrace.getNext(ctx);
-
- assertEquals(102, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- // Verify seek to first checkpoint
- seekTs = new TmfTimestamp(1, -3, 0);
- ctx = fTrace.seekEvent(seekTs);
- event = fTrace.getNext(ctx);
-
- assertEquals(1, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- // Verify seek to timestamp before first event
- seekTs = new TmfTimestamp(0, -3, 0);
- ctx = fTrace.seekEvent(seekTs);
- event = fTrace.getNext(ctx);
-
- assertEquals(1, ctx.getRank());
- assertEquals(0, new TmfTimestamp(1, -3, 0).compareTo(event.getTimestamp(), false));
-
- // Verify seek to timestamp between first and second checkpoint
- seekTs = new TmfTimestamp(50, -3, 0);
- ctx = fTrace.seekEvent(seekTs);
- event = fTrace.getNext(ctx);
-
- assertEquals(50, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- // Verify seek to timestamp after last event in trace
- seekTs = new TmfTimestamp(103, -3, 0);
- ctx = fTrace.seekEvent(seekTs);
- event = fTrace.getNext(ctx);
-
- assertEquals(-1, ctx.getRank());
- assertNull(event);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Francois Chouinard - Adapted for TMF Trace Model 1.0
- * Alexandre Montplaisir - Port to JUnit4
- * Patrick Tasse - Updated for location in checkpoint
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfCheckpoint class.
- */
-@SuppressWarnings("javadoc")
-public class TmfCheckpointTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private ITmfTimestamp fTimestamp1 = new TmfTimestamp();
- private ITmfTimestamp fTimestamp2 = TmfTimestamp.BIG_BANG;
- private ITmfTimestamp fTimestamp3 = TmfTimestamp.BIG_CRUNCH;
-
- private Long aLong1 = 12345L;
- private Long aLong2 = 23456L;
- private Long aLong3 = 34567L;
- private ITmfLocation fLocation1 = new TmfLongLocation(aLong1);
- private ITmfLocation fLocation2 = new TmfLongLocation(aLong2);
- private ITmfLocation fLocation3 = new TmfLongLocation(aLong3);
-
- private TmfCheckpoint fCheckpoint1 = new TmfCheckpoint(fTimestamp1, fLocation1);
- private TmfCheckpoint fCheckpoint2 = new TmfCheckpoint(fTimestamp2, fLocation2);
- private TmfCheckpoint fCheckpoint3 = new TmfCheckpoint(fTimestamp3, fLocation3);
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfCheckpoint() {
- assertEquals("TmfCheckpoint", fTimestamp1, fCheckpoint1.getTimestamp());
- assertEquals("TmfCheckpoint", fLocation1, fCheckpoint1.getLocation());
- }
-
- public void testTmfLocationCopy() {
- final TmfCheckpoint checkpoint = new TmfCheckpoint(fCheckpoint1);
-
- assertEquals("TmfCheckpoint", fTimestamp1, checkpoint.getTimestamp());
- assertEquals("TmfCheckpoint", fLocation1, checkpoint.getLocation());
- }
-
- @Test
- public void testTmfLocationCopy2() {
- try {
- new TmfCheckpoint(null);
- fail("null copy");
- }
- catch (final IllegalArgumentException e) {
- // Success
- }
- catch (final Exception e) {
- fail("wrong exception");
- }
- }
-
- // ------------------------------------------------------------------------
- // compareTo
- // ------------------------------------------------------------------------
-
- @Test
- public void testCompareTo() {
- assertEquals("compareTo", 0, fCheckpoint1.compareTo(fCheckpoint1));
- assertEquals("compareTo", 1, fCheckpoint1.compareTo(fCheckpoint2));
- assertEquals("compareTo", -1, fCheckpoint1.compareTo(fCheckpoint3));
-
- assertEquals("compareTo", -1, fCheckpoint2.compareTo(fCheckpoint1));
- assertEquals("compareTo", 0, fCheckpoint2.compareTo(fCheckpoint2));
- assertEquals("compareTo", -1, fCheckpoint2.compareTo(fCheckpoint3));
-
- assertEquals("compareTo", 1, fCheckpoint3.compareTo(fCheckpoint1));
- assertEquals("compareTo", 1, fCheckpoint3.compareTo(fCheckpoint2));
- assertEquals("compareTo", 0, fCheckpoint3.compareTo(fCheckpoint3));
- }
-
- @Test
- public void testCompareToNull() {
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(null, fLocation1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(null, fLocation2);
- final TmfCheckpoint checkpoint3 = new TmfCheckpoint(null, fLocation3);
- final TmfCheckpoint checkpoint4 = new TmfCheckpoint(null, fLocation1);
-
- // Test the various 'null' vs. '!null' combinations
- assertEquals("compareTo", 0, checkpoint1.compareTo(fCheckpoint1));
- assertEquals("compareTo", 0, fCheckpoint1.compareTo(checkpoint1));
- assertEquals("compareTo", -1, checkpoint1.compareTo(fCheckpoint2));
- assertEquals("compareTo", 1, fCheckpoint2.compareTo(checkpoint1));
- assertEquals("compareTo", -1, checkpoint1.compareTo(fCheckpoint3));
- assertEquals("compareTo", 1, fCheckpoint3.compareTo(checkpoint1));
-
- // Test the 'null' vs. 'null' combinations
- assertEquals("compareTo", 0, checkpoint1.compareTo(checkpoint4));
- assertEquals("compareTo", 0, checkpoint4.compareTo(checkpoint1));
- assertEquals("compareTo", -1, checkpoint1.compareTo(checkpoint2));
- assertEquals("compareTo", 1, checkpoint2.compareTo(checkpoint1));
- assertEquals("compareTo", -1, checkpoint1.compareTo(checkpoint3));
- assertEquals("compareTo", 1, checkpoint3.compareTo(checkpoint1));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fCheckpoint2);
-
- assertTrue("hashCode", fCheckpoint1.hashCode() == checkpoint1.hashCode());
- assertTrue("hashCode", fCheckpoint2.hashCode() == checkpoint2.hashCode());
-
- assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint2.hashCode());
- assertTrue("hashCode", fCheckpoint2.hashCode() != checkpoint1.hashCode());
- }
-
- @Test
- public void testHashCodeNull() {
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(null, fLocation1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fTimestamp1, null);
- final TmfCheckpoint checkpoint3 = new TmfCheckpoint(checkpoint1);
- final TmfCheckpoint checkpoint4 = new TmfCheckpoint(checkpoint2);
-
- assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint1.hashCode());
- assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint2.hashCode());
-
- assertTrue("hashCode", checkpoint1.hashCode() == checkpoint3.hashCode());
- assertTrue("hashCode", checkpoint2.hashCode() == checkpoint4.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fCheckpoint1.equals(fCheckpoint1));
- assertTrue("equals", fCheckpoint2.equals(fCheckpoint2));
-
- assertTrue("equals", !fCheckpoint1.equals(fCheckpoint2));
- assertTrue("equals", !fCheckpoint2.equals(fCheckpoint1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fCheckpoint2);
-
- assertTrue("equals", checkpoint1.equals(fCheckpoint1));
- assertTrue("equals", fCheckpoint1.equals(checkpoint1));
-
- assertTrue("equals", checkpoint2.equals(fCheckpoint2));
- assertTrue("equals", fCheckpoint2.equals(checkpoint2));
- }
-
- @Test
- public void testEqualsTransivity() {
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(checkpoint1);
- final TmfCheckpoint checkpoint3 = new TmfCheckpoint(checkpoint2);
-
- assertTrue("equals", checkpoint1.equals(checkpoint2));
- assertTrue("equals", checkpoint2.equals(checkpoint3));
- assertTrue("equals", checkpoint1.equals(checkpoint3));
- }
-
- @Test
- public void testNotEqual() {
- // Various checkpoints
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fTimestamp1, fLocation1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fTimestamp2, fLocation1);
- final TmfCheckpoint checkpoint3 = new TmfCheckpoint(fTimestamp1, fLocation2);
- final TmfCheckpoint checkpoint4 = new TmfCheckpoint(fTimestamp1, null);
- final TmfCheckpoint checkpoint5 = new TmfCheckpoint(null, fLocation1);
-
- // Null check
- assertFalse("equals", checkpoint1.equals(null));
-
- // Different types
- assertFalse("equals", checkpoint1.equals(new TmfTimestamp()));
-
- // Null locations/location
- assertFalse("equals", checkpoint1.equals(checkpoint4));
- assertFalse("equals", checkpoint1.equals(checkpoint5));
- assertFalse("equals", checkpoint4.equals(checkpoint1));
- assertFalse("equals", checkpoint5.equals(checkpoint1));
-
- // Different locations/location
- assertFalse("equals", checkpoint1.equals(checkpoint2));
- assertFalse("equals", checkpoint1.equals(checkpoint3));
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- final String expected1 = "TmfCheckpoint [fLocation=" + fCheckpoint1.getLocation() +
- ", fTimestamp=" + fCheckpoint1.getTimestamp() + "]";
- final String expected2 = "TmfCheckpoint [fLocation=" + fCheckpoint2.getLocation() +
- ", fTimestamp=" + fCheckpoint2.getTimestamp() + "]";
- final String expected3 = "TmfCheckpoint [fLocation=" + fCheckpoint3.getLocation() +
- ", fTimestamp=" + fCheckpoint3.getTimestamp() + "]";
-
- assertEquals("toString", expected1, fCheckpoint1.toString());
- assertEquals("toString", expected2, fCheckpoint2.toString());
- assertEquals("toString", expected3, fCheckpoint3.toString());
- }
-
-}
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import org.eclipse.linuxtools.tmf.core.tests.trace.location.TmfStringLocation;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
-import org.eclipse.linuxtools.tmf.core.trace.TmfTimestampLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfTimestampLocation;
import org.junit.Test;
/**
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Alexandre Montplaisir - Port to JUnit4
- * Patrick Tasse - Updated for ranks in experiment location
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.List;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfCheckpointIndexTest class.
- */
-@SuppressWarnings("javadoc")
-public class TmfExperimentCheckpointIndexTest {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private static final String DIRECTORY = "testfiles";
- private static final String TEST_STREAM1 = "O-Test-10K";
- private static final String TEST_STREAM2 = "E-Test-10K";
- private static final String EXPERIMENT = "MyExperiment";
- private static int NB_EVENTS = 20000;
- private static int BLOCK_SIZE = 1000;
-
- private static ITmfTrace[] fTestTraces;
- private static TmfExperimentStub fExperiment;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- setupTraces();
- fExperiment = new TmfExperimentStub(EXPERIMENT, fTestTraces, BLOCK_SIZE);
- fExperiment.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
- }
-
- @After
- public void tearDown() {
- fExperiment.dispose();
- fExperiment = null;
- for (ITmfTrace trace : fTestTraces) {
- trace.dispose();
- }
- fTestTraces = null;
- }
-
- private static void setupTraces() {
- final String path1 = DIRECTORY + File.separator + TEST_STREAM1;
- final String path2 = DIRECTORY + File.separator + TEST_STREAM2;
-
- fTestTraces = new ITmfTrace[2];
- 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);
- 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);
- fTestTraces[1] = trace2;
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- }
-
- // ------------------------------------------------------------------------
- // Verify checkpoints
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfTraceIndexing() {
- assertEquals("getCacheSize", BLOCK_SIZE, fExperiment.getCacheSize());
- assertEquals("getTraceSize", NB_EVENTS, fExperiment.getNbEvents());
- assertEquals("getRange-start", 1, fExperiment.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, fExperiment.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, fExperiment.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, fExperiment.getEndTime().getValue());
-
- List<ITmfCheckpoint> checkpoints = fExperiment.getIndexer().getCheckpoints();
- int pageSize = fExperiment.getCacheSize();
- assertTrue("Checkpoints exist", checkpoints != null);
- assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
-
- // Validate that each checkpoint points to the right event
- for (int i = 0; i < checkpoints.size(); i++) {
- ITmfCheckpoint checkpoint = checkpoints.get(i);
- ITmfLocation location = checkpoint.getLocation();
- ITmfContext context = fExperiment.seekEvent(location);
- ITmfEvent event = fExperiment.parseEvent(context);
- assertTrue(context.getRank() == i * pageSize);
- assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
- }
- }
-
- // ------------------------------------------------------------------------
- // Streaming
- // ------------------------------------------------------------------------
-
- @Test
- public void testGrowingIndex() {
- ITmfTrace[] testTraces = new TmfTraceStub[2];
- 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);
- 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);
- testTraces[1] = trace2;
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
-
- TmfExperimentStub experiment = new TmfExperimentStub(EXPERIMENT, testTraces, BLOCK_SIZE);
- int pageSize = experiment.getCacheSize();
-
- // Build the first half of the index
- TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(1, -3), new TmfTimestamp(NB_EVENTS / 2 - 1, -3));
- experiment.getIndexer().buildIndex(0, range, true);
-
- // Validate that each checkpoint points to the right event
- List<ITmfCheckpoint> checkpoints = experiment.getIndexer().getCheckpoints();
- assertTrue("Checkpoints exist", checkpoints != null);
- assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE / 2, checkpoints.size());
-
- // Build the second half of the index
- experiment.getIndexer().buildIndex(NB_EVENTS / 2, TmfTimeRange.ETERNITY, true);
-
- // Validate that each checkpoint points to the right event
- assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
- for (int i = 0; i < checkpoints.size(); i++) {
- ITmfCheckpoint checkpoint = checkpoints.get(i);
- ITmfLocation location = checkpoint.getLocation();
- ITmfContext context = experiment.seekEvent(location);
- ITmfEvent event = experiment.parseEvent(context);
- assertTrue(context.getRank() == i * pageSize);
- assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
- assertEquals("Checkpoint value", i * pageSize + 1, checkpoint.getTimestamp().getValue());
- }
-
- /* Clean up (since we didn't use the class-specific fixtures) */
- experiment.dispose();
- for (ITmfTrace trace : testTraces) {
- trace.dispose();
- }
- }
-
-}
\ No newline at end of file
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub;
import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
import org.junit.Before;
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Alexandre Montplaisir - Port to JUnit4
- * Patrick Tasse - Add tests for TmfExperimentLocation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentLocation;
-import org.eclipse.linuxtools.internal.tmf.core.trace.TmfLocationArray;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
-import org.eclipse.linuxtools.tmf.core.trace.TmfTimestampLocation;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfLocation class.
- */
-@SuppressWarnings("javadoc")
-public class TmfLocationTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private String aString = "some location";
- private Long aLong = 12345L;
- private TmfTimestamp aTimestamp = new TmfTimestamp();
- private TmfLocationArray aLocationArray;
-
- private TmfStringLocation fLocation1;
- private TmfStringLocation fLocation2;
- private TmfLongLocation fLocation3;
- private TmfTimestampLocation fLocation4;
- private TmfExperimentLocation fExpLocation;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- fLocation1 = new TmfStringLocation((String) null);
- fLocation2 = new TmfStringLocation(aString);
- fLocation3 = new TmfLongLocation(aLong);
- fLocation4 = new TmfTimestampLocation(aTimestamp);
- aLocationArray = new TmfLocationArray(
- new ITmfLocation[] { fLocation1, fLocation2, fLocation3, fLocation4 },
- new long[] { 1, 2, 3, 4 }
- );
- fExpLocation = new TmfExperimentLocation(aLocationArray);
- }
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfLocation() {
- assertNull("TmfLocation", fLocation1.getLocationInfo());
- assertEquals("TmfLocation", aString, fLocation2.getLocationInfo());
- assertEquals("TmfLocation", aLong, fLocation3.getLocationInfo());
- assertEquals("TmfLocation", aTimestamp, fLocation4.getLocationInfo());
- assertEquals("TmfLocation", aLocationArray, fExpLocation.getLocationInfo());
- }
-
- @Test
- public void testTmfLocationCopy() {
- TmfStringLocation location1 = new TmfStringLocation(fLocation1);
- TmfStringLocation location2 = new TmfStringLocation(fLocation2);
- TmfLongLocation location3 = new TmfLongLocation(fLocation3);
- TmfTimestampLocation location4 = new TmfTimestampLocation(fLocation4);
- TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation);
-
- assertNull("TmfLocation", location1.getLocationInfo());
- assertEquals("TmfLocation", aString, location2.getLocationInfo());
- assertEquals("TmfLocation", aLong, location3.getLocationInfo());
- assertEquals("TmfLocation", aTimestamp, location4.getLocationInfo());
- assertEquals("TmfLocation", aLocationArray, expLocation.getLocationInfo());
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- TmfStringLocation location1 = new TmfStringLocation((String) null);
- TmfStringLocation location2 = new TmfStringLocation(aString);
- TmfLongLocation location3 = new TmfLongLocation(aLong);
- TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation);
- TmfLocationArray locationArray1 = new TmfLocationArray(aLocationArray, 3, fLocation4, 5);
- TmfExperimentLocation expLocation1 = new TmfExperimentLocation(locationArray1);
- TmfLocationArray locationArray2 = new TmfLocationArray(aLocationArray, 3, fLocation3, 4);
- TmfExperimentLocation expLocation2 = new TmfExperimentLocation(locationArray2);
- TmfLocationArray locationArray3 = new TmfLocationArray(
- new ITmfLocation[] { fLocation1, fLocation2, fLocation3 },
- new long[] { 1, 2, 3 }
- );
- TmfExperimentLocation expLocation3 = new TmfExperimentLocation(locationArray3);
-
- assertTrue("hashCode", fLocation1.hashCode() == location1.hashCode());
- assertTrue("hashCode", fLocation2.hashCode() == location2.hashCode());
- assertTrue("hashCode", fLocation3.hashCode() == location3.hashCode());
- assertTrue("hashCode", fExpLocation.hashCode() == expLocation.hashCode());
-
- assertTrue("hashCode", fLocation2.hashCode() != location3.hashCode());
- assertTrue("hashCode", fLocation3.hashCode() != location2.hashCode());
- assertTrue("hashCode", fExpLocation.hashCode() != expLocation1.hashCode());
- assertTrue("hashCode", fExpLocation.hashCode() != expLocation2.hashCode());
- assertTrue("hashCode", fExpLocation.hashCode() != expLocation3.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // toEquals
- // ------------------------------------------------------------------------
-
- private static class TmfLocation2 extends TmfStringLocation {
- public TmfLocation2(String location) {
- super(location);
- }
- }
-
- @Test
- public void testEqualsWrongTypes() {
- ITmfLocation location1 = new TmfStringLocation(aString);
- TmfLocation2 location2 = new TmfLocation2(aString);
-
- assertFalse("equals", location1.equals(location2));
- assertFalse("equals", location2.equals(location1));
- }
-
- @Test
- public void testEqualsWithNulls() {
- TmfStringLocation location1 = new TmfStringLocation(aString);
- TmfStringLocation location2 = new TmfStringLocation((String) null);
-
- assertFalse("equals", location1.equals(location2));
- assertFalse("equals", location2.equals(location1));
- }
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fLocation2.equals(fLocation2));
- assertTrue("equals", fLocation3.equals(fLocation3));
- assertTrue("equals", fExpLocation.equals(fExpLocation));
-
- assertTrue("equals", !fLocation2.equals(fLocation3));
- assertTrue("equals", !fLocation3.equals(fLocation2));
- TmfLocationArray locationArray1 = new TmfLocationArray(aLocationArray, 3, fLocation4, 5);
- TmfExperimentLocation expLocation1 = new TmfExperimentLocation(locationArray1);
- TmfLocationArray locationArray2 = new TmfLocationArray(aLocationArray, 3, fLocation3, 4);
- TmfExperimentLocation expLocation2 = new TmfExperimentLocation(locationArray2);
- TmfLocationArray locationArray3 = new TmfLocationArray(
- new ITmfLocation[] { fLocation1, fLocation2, fLocation3 },
- new long[] { 1, 2, 3 }
- );
- TmfExperimentLocation expLocation3 = new TmfExperimentLocation(locationArray3);
- assertTrue("equals", !fExpLocation.equals(expLocation1));
- assertTrue("equals", !expLocation1.equals(fExpLocation));
- assertTrue("equals", !fExpLocation.equals(expLocation2));
- assertTrue("equals", !expLocation2.equals(fExpLocation));
- assertTrue("equals", !fExpLocation.equals(expLocation3));
- assertTrue("equals", !expLocation3.equals(fExpLocation));
- }
-
- @Test
- public void testEqualsSymmetry() {
- TmfStringLocation location2 = new TmfStringLocation(aString);
- TmfLongLocation location3 = new TmfLongLocation(aLong);
- TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation);
-
- assertTrue("equals", location2.equals(fLocation2));
- assertTrue("equals", fLocation2.equals(location2));
-
- assertTrue("equals", location3.equals(fLocation3));
- assertTrue("equals", fLocation3.equals(location3));
-
- assertTrue("equals", expLocation.equals(fExpLocation));
- assertTrue("equals", fExpLocation.equals(expLocation));
- }
-
- @Test
- public void testEqualsTransivity() {
- TmfStringLocation location1 = new TmfStringLocation(aString);
- TmfStringLocation location2 = new TmfStringLocation(aString);
- TmfStringLocation location3 = new TmfStringLocation(aString);
- TmfExperimentLocation expLocation1 = new TmfExperimentLocation(aLocationArray);
- TmfExperimentLocation expLocation2 = new TmfExperimentLocation(aLocationArray);
- TmfExperimentLocation expLocation3 = new TmfExperimentLocation(aLocationArray);
-
- assertTrue("equals", location1.equals(location2));
- assertTrue("equals", location2.equals(location3));
- assertTrue("equals", location3.equals(location1));
- assertTrue("equals", expLocation1.equals(expLocation2));
- assertTrue("equals", expLocation2.equals(expLocation3));
- assertTrue("equals", expLocation3.equals(expLocation1));
- }
-
- @Test
- public void testEqualsNull() {
- assertTrue("equals", !fLocation2.equals(null));
- assertTrue("equals", !fLocation2.equals(null));
- assertTrue("equals", !fExpLocation.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- String str = "some location";
- Long lng = 12345L;
- TmfTimestamp ts = new TmfTimestamp();
-
- TmfStringLocation location1 = new TmfStringLocation(str);
- TmfLongLocation location2 = new TmfLongLocation(lng);
- TmfTimestampLocation location3 = new TmfTimestampLocation(ts);
- TmfExperimentLocation expLocation = new TmfExperimentLocation(aLocationArray);
-
- String expected1 = "TmfStringLocation [fLocationInfo=" + str + "]";
- String expected2 = "TmfLongLocation [fLocationInfo=" + lng + "]";
- String expected3 = "TmfTimestampLocation [fLocationInfo=" + ts + "]";
- String expected4 = "TmfExperimentLocation [" + aLocationArray + "]";
-
- assertEquals("toString", expected1, location1.toString());
- assertEquals("toString", expected2, location2.toString());
- assertEquals("toString", expected3, location3.toString());
- assertEquals("toString", expected4, expLocation.toString());
- }
-
-}
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub;
import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
import org.junit.AfterClass;
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
-
-/**
- * <b><u>TmfStringLocation</u></b>
- * <p>
- * Implement me. Please.
- * <p>
- */
-public class TmfStringLocation extends TmfLocation {
-
- /**
- * @param location the concrete trace location
- */
- public TmfStringLocation(String location) {
- super(location);
- }
-
- /**
- * @param other the other location
- */
- public TmfStringLocation(TmfStringLocation other) {
- super(other.getLocationInfo());
- }
-
- @Override
- public String getLocationInfo() {
- return (String) super.getLocationInfo();
- }
-
-}
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
import org.junit.After;
import org.junit.Before;
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexandre Montplaisir - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite for org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TmfCheckpointIndexTest.class,
+ TmfCheckpointIndexTest2.class,
+ TmfCheckpointTest.class,
+ TmfExperimentCheckpointIndexTest.class,
+})
+public class AllTests {}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Adapted for TMF Trace Model 1.0
+ * Alexandre Montplaisir - Port to JUnit4
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfEmptyTraceStub;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test suite for the TmfCheckpointIndexTest class.
+ */
+@SuppressWarnings("javadoc")
+public class TmfCheckpointIndexTest {
+
+ // ------------------------------------------------------------------------
+ // Variables
+ // ------------------------------------------------------------------------
+
+ private static final String DIRECTORY = "testfiles";
+ private static final String TEST_STREAM = "A-Test-10K";
+ private static final int BLOCK_SIZE = 100;
+ private static final int NB_EVENTS = 10000;
+ private static TestTrace fTrace = null;
+ private static EmptyTestTrace fEmptyTrace = null;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ @Before
+ public void setUp() {
+ setupTrace(DIRECTORY + File.separator + TEST_STREAM);
+ }
+
+ @After
+ public void tearDown() {
+ fTrace.dispose();
+ fTrace = null;
+ fEmptyTrace.dispose();
+ fEmptyTrace = null;
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper classes
+ // ------------------------------------------------------------------------
+
+ private static class TestIndexer extends TmfCheckpointIndexer {
+ @SuppressWarnings({ })
+ public TestIndexer(TestTrace testTrace) {
+ super(testTrace, BLOCK_SIZE);
+ }
+ @SuppressWarnings({ })
+ public TestIndexer(EmptyTestTrace testTrace) {
+ super(testTrace, BLOCK_SIZE);
+ }
+ public List<ITmfCheckpoint> getCheckpoints() {
+ return getTraceIndex();
+ }
+ }
+
+ private class TestTrace extends TmfTraceStub {
+ public TestTrace(String path, int blockSize) throws TmfTraceException {
+ super(path, blockSize);
+ setIndexer(new TestIndexer(this));
+ }
+ @Override
+ public TestIndexer getIndexer() {
+ return (TestIndexer) super.getIndexer();
+ }
+ }
+
+ private class EmptyTestTrace extends TmfEmptyTraceStub {
+ public EmptyTestTrace() {
+ super();
+ setIndexer(new TestIndexer(this));
+ }
+ @Override
+ public TestIndexer getIndexer() {
+ return (TestIndexer) super.getIndexer();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper functions
+ // ------------------------------------------------------------------------
+
+ private synchronized void setupTrace(final String path) {
+ if (fTrace == null) {
+ try {
+ final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
+ final File test = new File(FileLocator.toFileURL(location).toURI());
+ fTrace = new TestTrace(test.toURI().getPath(), BLOCK_SIZE);
+ fTrace.indexTrace(true);
+ } catch (final TmfTraceException e) {
+ e.printStackTrace();
+ } catch (final URISyntaxException e) {
+ e.printStackTrace();
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (fEmptyTrace == null) {
+ fEmptyTrace = new EmptyTestTrace();
+ fEmptyTrace.indexTrace(true);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Verify checkpoints
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testTmfTraceIndexing() {
+ assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize());
+ assertEquals("getTraceSize", NB_EVENTS, fTrace.getNbEvents());
+ assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue());
+ assertEquals("getRange-end", NB_EVENTS, fTrace.getTimeRange().getEndTime().getValue());
+ assertEquals("getStartTime", 1, fTrace.getStartTime().getValue());
+ assertEquals("getEndTime", NB_EVENTS, fTrace.getEndTime().getValue());
+
+ List<ITmfCheckpoint> checkpoints = fTrace.getIndexer().getCheckpoints();
+ int pageSize = fTrace.getCacheSize();
+ assertTrue("Checkpoints exist", checkpoints != null);
+ assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
+
+ // Validate that each checkpoint points to the right event
+ for (int i = 0; i < checkpoints.size(); i++) {
+ ITmfCheckpoint checkpoint = checkpoints.get(i);
+ TmfContext context = new TmfContext(checkpoint.getLocation(), i * pageSize);
+ ITmfEvent event = fTrace.parseEvent(context);
+ assertTrue(context.getRank() == i * pageSize);
+ assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
+ }
+ }
+
+ @Test
+ public void testEmptyTmfTraceIndexing() {
+ assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, fEmptyTrace.getCacheSize());
+ assertEquals("getTraceSize", 0, fEmptyTrace.getNbEvents());
+ assertEquals("getRange-start", TmfTimestamp.BIG_BANG, fEmptyTrace.getTimeRange().getStartTime());
+ assertEquals("getRange-end", TmfTimestamp.BIG_BANG, fEmptyTrace.getTimeRange().getEndTime());
+ assertEquals("getStartTime", TmfTimestamp.BIG_BANG, fEmptyTrace.getStartTime());
+ assertEquals("getEndTime", TmfTimestamp.BIG_BANG, fEmptyTrace.getEndTime());
+
+ List<ITmfCheckpoint> checkpoints = fEmptyTrace.getIndexer().getCheckpoints();
+ int pageSize = fEmptyTrace.getCacheSize();
+ assertTrue("Checkpoints exist", checkpoints != null);
+ assertEquals("Checkpoints size", 0, checkpoints.size());
+
+ // Validate that each checkpoint points to the right event
+ for (int i = 0; i < checkpoints.size(); i++) {
+ ITmfCheckpoint checkpoint = checkpoints.get(i);
+ TmfContext context = new TmfContext(checkpoint.getLocation(), i * pageSize);
+ ITmfEvent event = fEmptyTrace.parseEvent(context);
+ assertTrue(context.getRank() == i * pageSize);
+ assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
+ }
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ * Alexandre Montplaisir - Port to JUnit4
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfEmptyTraceStub;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test suite for the TmfCheckpointIndexer class (events with same
+ * timestamp around checkpoint).
+ */
+@SuppressWarnings("javadoc")
+public class TmfCheckpointIndexTest2 {
+
+ // ------------------------------------------------------------------------
+ // Variables
+ // ------------------------------------------------------------------------
+
+ private static final String DIRECTORY = "testfiles";
+ // Trace has 3 events at t=101 at rank 99, 100, 101
+ // Trace has events with same timestamp (ts=102) for ranks 102..702 -> 2 checkpoints with same timestamp are created
+ private static final String TEST_STREAM = "A-Test-10K-2";
+ private static final int BLOCK_SIZE = 100;
+ private static final int NB_EVENTS = 702;
+ private static TestTrace fTrace = null;
+ private static EmptyTestTrace fEmptyTrace = null;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ @Before
+ public void setUp() {
+ setupTrace(DIRECTORY + File.separator + TEST_STREAM);
+ }
+
+ @After
+ public void tearDown() {
+ fTrace.dispose();
+ fTrace = null;
+ fEmptyTrace.dispose();
+ fEmptyTrace = null;
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper classes
+ // ------------------------------------------------------------------------
+
+ private static class TestIndexer extends TmfCheckpointIndexer {
+ @SuppressWarnings({ })
+ public TestIndexer(TestTrace testTrace) {
+ super(testTrace, BLOCK_SIZE);
+ }
+ @SuppressWarnings({ })
+ public TestIndexer(EmptyTestTrace testTrace) {
+ super(testTrace, BLOCK_SIZE);
+ }
+ public List<ITmfCheckpoint> getCheckpoints() {
+ return getTraceIndex();
+ }
+ }
+
+ private class TestTrace extends TmfTraceStub {
+ public TestTrace(String path, int blockSize) throws TmfTraceException {
+ super(path, blockSize);
+ setIndexer(new TestIndexer(this));
+ }
+ @Override
+ public TestIndexer getIndexer() {
+ return (TestIndexer) super.getIndexer();
+ }
+ }
+
+ private class EmptyTestTrace extends TmfEmptyTraceStub {
+ public EmptyTestTrace() {
+ super();
+ setIndexer(new TestIndexer(this));
+ }
+ @Override
+ public TestIndexer getIndexer() {
+ return (TestIndexer) super.getIndexer();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper functions
+ // ------------------------------------------------------------------------
+
+ private synchronized void setupTrace(final String path) {
+ if (fTrace == null) {
+ try {
+ final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
+ final File test = new File(FileLocator.toFileURL(location).toURI());
+ fTrace = new TestTrace(test.toURI().getPath(), BLOCK_SIZE);
+ fTrace.indexTrace(true);
+ } catch (final TmfTraceException e) {
+ e.printStackTrace();
+ } catch (final URISyntaxException e) {
+ e.printStackTrace();
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (fEmptyTrace == null) {
+ fEmptyTrace = new EmptyTestTrace();
+ fEmptyTrace.indexTrace(true);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Verify checkpoints
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testTmfTraceMultiTimestamps() {
+ assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize());
+ assertEquals("getTraceSize", NB_EVENTS, fTrace.getNbEvents());
+ assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue());
+ assertEquals("getRange-end", 102, fTrace.getTimeRange().getEndTime().getValue());
+ assertEquals("getStartTime", 1, fTrace.getStartTime().getValue());
+ assertEquals("getEndTime", 102, fTrace.getEndTime().getValue());
+
+ List<ITmfCheckpoint> checkpoints = fTrace.getIndexer().getCheckpoints();
+ assertTrue("Checkpoints exist", checkpoints != null);
+ assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE + 1, checkpoints.size());
+
+ // Trace has 3 events with same timestamp (ts=101) at rank 99, 100, 101
+
+ // Verify that the event at rank=99 is returned when seeking to ts=101 (first event with this timestamp)
+ // and not the event at checkpoint boundary
+ TmfTimestamp seekTs = new TmfTimestamp(101, -3, 0);
+ ITmfContext ctx = fTrace.seekEvent(seekTs);
+ ITmfEvent event = fTrace.getNext(ctx);
+
+ assertEquals(99, ctx.getRank());
+ assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
+
+ event = fTrace.getNext(ctx);
+
+ assertEquals(100, ctx.getRank());
+ assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
+
+ event = fTrace.getNext(ctx);
+
+ assertEquals(101, ctx.getRank());
+ assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
+
+ // Trace has events with same timestamp (ts=102) for ranks 102..702 -> 2 checkpoints with same timestamp are created
+ // Verify that the event at rank=102 is returned when seeking to ts=102 (first event with this timestamp)
+ // and not the event at checkpoint boundary
+ seekTs = new TmfTimestamp(102, -3, 0);
+ ctx = fTrace.seekEvent(seekTs);
+ event = fTrace.getNext(ctx);
+
+ assertEquals(102, ctx.getRank());
+ assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
+
+ // Verify seek to first checkpoint
+ seekTs = new TmfTimestamp(1, -3, 0);
+ ctx = fTrace.seekEvent(seekTs);
+ event = fTrace.getNext(ctx);
+
+ assertEquals(1, ctx.getRank());
+ assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
+
+ // Verify seek to timestamp before first event
+ seekTs = new TmfTimestamp(0, -3, 0);
+ ctx = fTrace.seekEvent(seekTs);
+ event = fTrace.getNext(ctx);
+
+ assertEquals(1, ctx.getRank());
+ assertEquals(0, new TmfTimestamp(1, -3, 0).compareTo(event.getTimestamp(), false));
+
+ // Verify seek to timestamp between first and second checkpoint
+ seekTs = new TmfTimestamp(50, -3, 0);
+ ctx = fTrace.seekEvent(seekTs);
+ event = fTrace.getNext(ctx);
+
+ assertEquals(50, ctx.getRank());
+ assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
+
+ // Verify seek to timestamp after last event in trace
+ seekTs = new TmfTimestamp(103, -3, 0);
+ ctx = fTrace.seekEvent(seekTs);
+ event = fTrace.getNext(ctx);
+
+ assertEquals(-1, ctx.getRank());
+ assertNull(event);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Adapted for TMF Trace Model 1.0
+ * Alexandre Montplaisir - Port to JUnit4
+ * Patrick Tasse - Updated for location in checkpoint
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpoint;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
+import org.junit.Test;
+
+/**
+ * Test suite for the TmfCheckpoint class.
+ */
+@SuppressWarnings("javadoc")
+public class TmfCheckpointTest {
+
+ // ------------------------------------------------------------------------
+ // Variables
+ // ------------------------------------------------------------------------
+
+ private ITmfTimestamp fTimestamp1 = new TmfTimestamp();
+ private ITmfTimestamp fTimestamp2 = TmfTimestamp.BIG_BANG;
+ private ITmfTimestamp fTimestamp3 = TmfTimestamp.BIG_CRUNCH;
+
+ private Long aLong1 = 12345L;
+ private Long aLong2 = 23456L;
+ private Long aLong3 = 34567L;
+ private ITmfLocation fLocation1 = new TmfLongLocation(aLong1);
+ private ITmfLocation fLocation2 = new TmfLongLocation(aLong2);
+ private ITmfLocation fLocation3 = new TmfLongLocation(aLong3);
+
+ private TmfCheckpoint fCheckpoint1 = new TmfCheckpoint(fTimestamp1, fLocation1);
+ private TmfCheckpoint fCheckpoint2 = new TmfCheckpoint(fTimestamp2, fLocation2);
+ private TmfCheckpoint fCheckpoint3 = new TmfCheckpoint(fTimestamp3, fLocation3);
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testTmfCheckpoint() {
+ assertEquals("TmfCheckpoint", fTimestamp1, fCheckpoint1.getTimestamp());
+ assertEquals("TmfCheckpoint", fLocation1, fCheckpoint1.getLocation());
+ }
+
+ public void testTmfLocationCopy() {
+ final TmfCheckpoint checkpoint = new TmfCheckpoint(fCheckpoint1);
+
+ assertEquals("TmfCheckpoint", fTimestamp1, checkpoint.getTimestamp());
+ assertEquals("TmfCheckpoint", fLocation1, checkpoint.getLocation());
+ }
+
+ @Test
+ public void testTmfLocationCopy2() {
+ try {
+ new TmfCheckpoint(null);
+ fail("null copy");
+ }
+ catch (final IllegalArgumentException e) {
+ // Success
+ }
+ catch (final Exception e) {
+ fail("wrong exception");
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // compareTo
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testCompareTo() {
+ assertEquals("compareTo", 0, fCheckpoint1.compareTo(fCheckpoint1));
+ assertEquals("compareTo", 1, fCheckpoint1.compareTo(fCheckpoint2));
+ assertEquals("compareTo", -1, fCheckpoint1.compareTo(fCheckpoint3));
+
+ assertEquals("compareTo", -1, fCheckpoint2.compareTo(fCheckpoint1));
+ assertEquals("compareTo", 0, fCheckpoint2.compareTo(fCheckpoint2));
+ assertEquals("compareTo", -1, fCheckpoint2.compareTo(fCheckpoint3));
+
+ assertEquals("compareTo", 1, fCheckpoint3.compareTo(fCheckpoint1));
+ assertEquals("compareTo", 1, fCheckpoint3.compareTo(fCheckpoint2));
+ assertEquals("compareTo", 0, fCheckpoint3.compareTo(fCheckpoint3));
+ }
+
+ @Test
+ public void testCompareToNull() {
+ final TmfCheckpoint checkpoint1 = new TmfCheckpoint(null, fLocation1);
+ final TmfCheckpoint checkpoint2 = new TmfCheckpoint(null, fLocation2);
+ final TmfCheckpoint checkpoint3 = new TmfCheckpoint(null, fLocation3);
+ final TmfCheckpoint checkpoint4 = new TmfCheckpoint(null, fLocation1);
+
+ // Test the various 'null' vs. '!null' combinations
+ assertEquals("compareTo", 0, checkpoint1.compareTo(fCheckpoint1));
+ assertEquals("compareTo", 0, fCheckpoint1.compareTo(checkpoint1));
+ assertEquals("compareTo", -1, checkpoint1.compareTo(fCheckpoint2));
+ assertEquals("compareTo", 1, fCheckpoint2.compareTo(checkpoint1));
+ assertEquals("compareTo", -1, checkpoint1.compareTo(fCheckpoint3));
+ assertEquals("compareTo", 1, fCheckpoint3.compareTo(checkpoint1));
+
+ // Test the 'null' vs. 'null' combinations
+ assertEquals("compareTo", 0, checkpoint1.compareTo(checkpoint4));
+ assertEquals("compareTo", 0, checkpoint4.compareTo(checkpoint1));
+ assertEquals("compareTo", -1, checkpoint1.compareTo(checkpoint2));
+ assertEquals("compareTo", 1, checkpoint2.compareTo(checkpoint1));
+ assertEquals("compareTo", -1, checkpoint1.compareTo(checkpoint3));
+ assertEquals("compareTo", 1, checkpoint3.compareTo(checkpoint1));
+ }
+
+ // ------------------------------------------------------------------------
+ // hashCode
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testHashCode() {
+ final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
+ final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fCheckpoint2);
+
+ assertTrue("hashCode", fCheckpoint1.hashCode() == checkpoint1.hashCode());
+ assertTrue("hashCode", fCheckpoint2.hashCode() == checkpoint2.hashCode());
+
+ assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint2.hashCode());
+ assertTrue("hashCode", fCheckpoint2.hashCode() != checkpoint1.hashCode());
+ }
+
+ @Test
+ public void testHashCodeNull() {
+ final TmfCheckpoint checkpoint1 = new TmfCheckpoint(null, fLocation1);
+ final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fTimestamp1, null);
+ final TmfCheckpoint checkpoint3 = new TmfCheckpoint(checkpoint1);
+ final TmfCheckpoint checkpoint4 = new TmfCheckpoint(checkpoint2);
+
+ assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint1.hashCode());
+ assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint2.hashCode());
+
+ assertTrue("hashCode", checkpoint1.hashCode() == checkpoint3.hashCode());
+ assertTrue("hashCode", checkpoint2.hashCode() == checkpoint4.hashCode());
+ }
+
+ // ------------------------------------------------------------------------
+ // equals
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testEqualsReflexivity() {
+ assertTrue("equals", fCheckpoint1.equals(fCheckpoint1));
+ assertTrue("equals", fCheckpoint2.equals(fCheckpoint2));
+
+ assertTrue("equals", !fCheckpoint1.equals(fCheckpoint2));
+ assertTrue("equals", !fCheckpoint2.equals(fCheckpoint1));
+ }
+
+ @Test
+ public void testEqualsSymmetry() {
+ final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
+ final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fCheckpoint2);
+
+ assertTrue("equals", checkpoint1.equals(fCheckpoint1));
+ assertTrue("equals", fCheckpoint1.equals(checkpoint1));
+
+ assertTrue("equals", checkpoint2.equals(fCheckpoint2));
+ assertTrue("equals", fCheckpoint2.equals(checkpoint2));
+ }
+
+ @Test
+ public void testEqualsTransivity() {
+ final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
+ final TmfCheckpoint checkpoint2 = new TmfCheckpoint(checkpoint1);
+ final TmfCheckpoint checkpoint3 = new TmfCheckpoint(checkpoint2);
+
+ assertTrue("equals", checkpoint1.equals(checkpoint2));
+ assertTrue("equals", checkpoint2.equals(checkpoint3));
+ assertTrue("equals", checkpoint1.equals(checkpoint3));
+ }
+
+ @Test
+ public void testNotEqual() {
+ // Various checkpoints
+ final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fTimestamp1, fLocation1);
+ final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fTimestamp2, fLocation1);
+ final TmfCheckpoint checkpoint3 = new TmfCheckpoint(fTimestamp1, fLocation2);
+ final TmfCheckpoint checkpoint4 = new TmfCheckpoint(fTimestamp1, null);
+ final TmfCheckpoint checkpoint5 = new TmfCheckpoint(null, fLocation1);
+
+ // Null check
+ assertFalse("equals", checkpoint1.equals(null));
+
+ // Different types
+ assertFalse("equals", checkpoint1.equals(new TmfTimestamp()));
+
+ // Null locations/location
+ assertFalse("equals", checkpoint1.equals(checkpoint4));
+ assertFalse("equals", checkpoint1.equals(checkpoint5));
+ assertFalse("equals", checkpoint4.equals(checkpoint1));
+ assertFalse("equals", checkpoint5.equals(checkpoint1));
+
+ // Different locations/location
+ assertFalse("equals", checkpoint1.equals(checkpoint2));
+ assertFalse("equals", checkpoint1.equals(checkpoint3));
+ }
+
+ // ------------------------------------------------------------------------
+ // toString
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testToString() {
+ final String expected1 = "TmfCheckpoint [fLocation=" + fCheckpoint1.getLocation() +
+ ", fTimestamp=" + fCheckpoint1.getTimestamp() + "]";
+ final String expected2 = "TmfCheckpoint [fLocation=" + fCheckpoint2.getLocation() +
+ ", fTimestamp=" + fCheckpoint2.getTimestamp() + "]";
+ final String expected3 = "TmfCheckpoint [fLocation=" + fCheckpoint3.getLocation() +
+ ", fTimestamp=" + fCheckpoint3.getTimestamp() + "]";
+
+ assertEquals("toString", expected1, fCheckpoint1.toString());
+ assertEquals("toString", expected2, fCheckpoint2.toString());
+ assertEquals("toString", expected3, fCheckpoint3.toString());
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Alexandre Montplaisir - Port to JUnit4
+ * Patrick Tasse - Updated for ranks in experiment location
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test suite for the TmfCheckpointIndexTest class.
+ */
+@SuppressWarnings("javadoc")
+public class TmfExperimentCheckpointIndexTest {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ private static final String DIRECTORY = "testfiles";
+ private static final String TEST_STREAM1 = "O-Test-10K";
+ private static final String TEST_STREAM2 = "E-Test-10K";
+ private static final String EXPERIMENT = "MyExperiment";
+ private static int NB_EVENTS = 20000;
+ private static int BLOCK_SIZE = 1000;
+
+ private static ITmfTrace[] fTestTraces;
+ private static TmfExperimentStub fExperiment;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ @Before
+ public void setUp() {
+ setupTraces();
+ fExperiment = new TmfExperimentStub(EXPERIMENT, fTestTraces, BLOCK_SIZE);
+ fExperiment.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
+ }
+
+ @After
+ public void tearDown() {
+ fExperiment.dispose();
+ fExperiment = null;
+ for (ITmfTrace trace : fTestTraces) {
+ trace.dispose();
+ }
+ fTestTraces = null;
+ }
+
+ private static void setupTraces() {
+ final String path1 = DIRECTORY + File.separator + TEST_STREAM1;
+ final String path2 = DIRECTORY + File.separator + TEST_STREAM2;
+
+ fTestTraces = new ITmfTrace[2];
+ 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);
+ 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);
+ fTestTraces[1] = trace2;
+ } catch (final TmfTraceException e) {
+ e.printStackTrace();
+ } catch (final URISyntaxException e) {
+ e.printStackTrace();
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Verify checkpoints
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testTmfTraceIndexing() {
+ assertEquals("getCacheSize", BLOCK_SIZE, fExperiment.getCacheSize());
+ assertEquals("getTraceSize", NB_EVENTS, fExperiment.getNbEvents());
+ assertEquals("getRange-start", 1, fExperiment.getTimeRange().getStartTime().getValue());
+ assertEquals("getRange-end", NB_EVENTS, fExperiment.getTimeRange().getEndTime().getValue());
+ assertEquals("getStartTime", 1, fExperiment.getStartTime().getValue());
+ assertEquals("getEndTime", NB_EVENTS, fExperiment.getEndTime().getValue());
+
+ List<ITmfCheckpoint> checkpoints = fExperiment.getIndexer().getCheckpoints();
+ int pageSize = fExperiment.getCacheSize();
+ assertTrue("Checkpoints exist", checkpoints != null);
+ assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
+
+ // Validate that each checkpoint points to the right event
+ for (int i = 0; i < checkpoints.size(); i++) {
+ ITmfCheckpoint checkpoint = checkpoints.get(i);
+ ITmfLocation location = checkpoint.getLocation();
+ ITmfContext context = fExperiment.seekEvent(location);
+ ITmfEvent event = fExperiment.parseEvent(context);
+ assertTrue(context.getRank() == i * pageSize);
+ assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Streaming
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testGrowingIndex() {
+ ITmfTrace[] testTraces = new TmfTraceStub[2];
+ 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);
+ 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);
+ testTraces[1] = trace2;
+ } catch (final TmfTraceException e) {
+ e.printStackTrace();
+ } catch (final URISyntaxException e) {
+ e.printStackTrace();
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+
+ TmfExperimentStub experiment = new TmfExperimentStub(EXPERIMENT, testTraces, BLOCK_SIZE);
+ int pageSize = experiment.getCacheSize();
+
+ // Build the first half of the index
+ TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(1, -3), new TmfTimestamp(NB_EVENTS / 2 - 1, -3));
+ experiment.getIndexer().buildIndex(0, range, true);
+
+ // Validate that each checkpoint points to the right event
+ List<ITmfCheckpoint> checkpoints = experiment.getIndexer().getCheckpoints();
+ assertTrue("Checkpoints exist", checkpoints != null);
+ assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE / 2, checkpoints.size());
+
+ // Build the second half of the index
+ experiment.getIndexer().buildIndex(NB_EVENTS / 2, TmfTimeRange.ETERNITY, true);
+
+ // Validate that each checkpoint points to the right event
+ assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
+ for (int i = 0; i < checkpoints.size(); i++) {
+ ITmfCheckpoint checkpoint = checkpoints.get(i);
+ ITmfLocation location = checkpoint.getLocation();
+ ITmfContext context = experiment.seekEvent(location);
+ ITmfEvent event = experiment.parseEvent(context);
+ assertTrue(context.getRank() == i * pageSize);
+ assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
+ assertEquals("Checkpoint value", i * pageSize + 1, checkpoint.getTimestamp().getValue());
+ }
+
+ /* Clean up (since we didn't use the class-specific fixtures) */
+ experiment.dispose();
+ for (ITmfTrace trace : testTraces) {
+ trace.dispose();
+ }
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Adjusted for new Trace Model
+ * Alexandre Montplaisir - Port to JUnit4
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.location;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite for org.eclipse.linuxtools.tmf.core.trace.location
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TmfLocationTest.class,
+})
+public class AllTests {}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Alexandre Montplaisir - Port to JUnit4
+ * Patrick Tasse - Add tests for TmfExperimentLocation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.location;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentLocation;
+import org.eclipse.linuxtools.internal.tmf.core.trace.TmfLocationArray;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfTimestampLocation;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test suite for the TmfLocation class.
+ */
+@SuppressWarnings("javadoc")
+public class TmfLocationTest {
+
+ // ------------------------------------------------------------------------
+ // Variables
+ // ------------------------------------------------------------------------
+
+ private String aString = "some location";
+ private Long aLong = 12345L;
+ private TmfTimestamp aTimestamp = new TmfTimestamp();
+ private TmfLocationArray aLocationArray;
+
+ private TmfStringLocation fLocation1;
+ private TmfStringLocation fLocation2;
+ private TmfLongLocation fLocation3;
+ private TmfTimestampLocation fLocation4;
+ private TmfExperimentLocation fExpLocation;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ @Before
+ public void setUp() {
+ fLocation1 = new TmfStringLocation((String) null);
+ fLocation2 = new TmfStringLocation(aString);
+ fLocation3 = new TmfLongLocation(aLong);
+ fLocation4 = new TmfTimestampLocation(aTimestamp);
+ aLocationArray = new TmfLocationArray(
+ new ITmfLocation[] { fLocation1, fLocation2, fLocation3, fLocation4 },
+ new long[] { 1, 2, 3, 4 }
+ );
+ fExpLocation = new TmfExperimentLocation(aLocationArray);
+ }
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testTmfLocation() {
+ assertNull("TmfLocation", fLocation1.getLocationInfo());
+ assertEquals("TmfLocation", aString, fLocation2.getLocationInfo());
+ assertEquals("TmfLocation", aLong, fLocation3.getLocationInfo());
+ assertEquals("TmfLocation", aTimestamp, fLocation4.getLocationInfo());
+ assertEquals("TmfLocation", aLocationArray, fExpLocation.getLocationInfo());
+ }
+
+ @Test
+ public void testTmfLocationCopy() {
+ TmfStringLocation location1 = new TmfStringLocation(fLocation1);
+ TmfStringLocation location2 = new TmfStringLocation(fLocation2);
+ TmfLongLocation location3 = new TmfLongLocation(fLocation3);
+ TmfTimestampLocation location4 = new TmfTimestampLocation(fLocation4);
+ TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation);
+
+ assertNull("TmfLocation", location1.getLocationInfo());
+ assertEquals("TmfLocation", aString, location2.getLocationInfo());
+ assertEquals("TmfLocation", aLong, location3.getLocationInfo());
+ assertEquals("TmfLocation", aTimestamp, location4.getLocationInfo());
+ assertEquals("TmfLocation", aLocationArray, expLocation.getLocationInfo());
+ }
+
+ // ------------------------------------------------------------------------
+ // hashCode
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testHashCode() {
+ TmfStringLocation location1 = new TmfStringLocation((String) null);
+ TmfStringLocation location2 = new TmfStringLocation(aString);
+ TmfLongLocation location3 = new TmfLongLocation(aLong);
+ TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation);
+ TmfLocationArray locationArray1 = new TmfLocationArray(aLocationArray, 3, fLocation4, 5);
+ TmfExperimentLocation expLocation1 = new TmfExperimentLocation(locationArray1);
+ TmfLocationArray locationArray2 = new TmfLocationArray(aLocationArray, 3, fLocation3, 4);
+ TmfExperimentLocation expLocation2 = new TmfExperimentLocation(locationArray2);
+ TmfLocationArray locationArray3 = new TmfLocationArray(
+ new ITmfLocation[] { fLocation1, fLocation2, fLocation3 },
+ new long[] { 1, 2, 3 }
+ );
+ TmfExperimentLocation expLocation3 = new TmfExperimentLocation(locationArray3);
+
+ assertTrue("hashCode", fLocation1.hashCode() == location1.hashCode());
+ assertTrue("hashCode", fLocation2.hashCode() == location2.hashCode());
+ assertTrue("hashCode", fLocation3.hashCode() == location3.hashCode());
+ assertTrue("hashCode", fExpLocation.hashCode() == expLocation.hashCode());
+
+ assertTrue("hashCode", fLocation2.hashCode() != location3.hashCode());
+ assertTrue("hashCode", fLocation3.hashCode() != location2.hashCode());
+ assertTrue("hashCode", fExpLocation.hashCode() != expLocation1.hashCode());
+ assertTrue("hashCode", fExpLocation.hashCode() != expLocation2.hashCode());
+ assertTrue("hashCode", fExpLocation.hashCode() != expLocation3.hashCode());
+ }
+
+ // ------------------------------------------------------------------------
+ // toEquals
+ // ------------------------------------------------------------------------
+
+ private static class TmfLocation2 extends TmfStringLocation {
+ public TmfLocation2(String location) {
+ super(location);
+ }
+ }
+
+ @Test
+ public void testEqualsWrongTypes() {
+ ITmfLocation location1 = new TmfStringLocation(aString);
+ TmfLocation2 location2 = new TmfLocation2(aString);
+
+ assertFalse("equals", location1.equals(location2));
+ assertFalse("equals", location2.equals(location1));
+ }
+
+ @Test
+ public void testEqualsWithNulls() {
+ TmfStringLocation location1 = new TmfStringLocation(aString);
+ TmfStringLocation location2 = new TmfStringLocation((String) null);
+
+ assertFalse("equals", location1.equals(location2));
+ assertFalse("equals", location2.equals(location1));
+ }
+
+ @Test
+ public void testEqualsReflexivity() {
+ assertTrue("equals", fLocation2.equals(fLocation2));
+ assertTrue("equals", fLocation3.equals(fLocation3));
+ assertTrue("equals", fExpLocation.equals(fExpLocation));
+
+ assertTrue("equals", !fLocation2.equals(fLocation3));
+ assertTrue("equals", !fLocation3.equals(fLocation2));
+ TmfLocationArray locationArray1 = new TmfLocationArray(aLocationArray, 3, fLocation4, 5);
+ TmfExperimentLocation expLocation1 = new TmfExperimentLocation(locationArray1);
+ TmfLocationArray locationArray2 = new TmfLocationArray(aLocationArray, 3, fLocation3, 4);
+ TmfExperimentLocation expLocation2 = new TmfExperimentLocation(locationArray2);
+ TmfLocationArray locationArray3 = new TmfLocationArray(
+ new ITmfLocation[] { fLocation1, fLocation2, fLocation3 },
+ new long[] { 1, 2, 3 }
+ );
+ TmfExperimentLocation expLocation3 = new TmfExperimentLocation(locationArray3);
+ assertTrue("equals", !fExpLocation.equals(expLocation1));
+ assertTrue("equals", !expLocation1.equals(fExpLocation));
+ assertTrue("equals", !fExpLocation.equals(expLocation2));
+ assertTrue("equals", !expLocation2.equals(fExpLocation));
+ assertTrue("equals", !fExpLocation.equals(expLocation3));
+ assertTrue("equals", !expLocation3.equals(fExpLocation));
+ }
+
+ @Test
+ public void testEqualsSymmetry() {
+ TmfStringLocation location2 = new TmfStringLocation(aString);
+ TmfLongLocation location3 = new TmfLongLocation(aLong);
+ TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation);
+
+ assertTrue("equals", location2.equals(fLocation2));
+ assertTrue("equals", fLocation2.equals(location2));
+
+ assertTrue("equals", location3.equals(fLocation3));
+ assertTrue("equals", fLocation3.equals(location3));
+
+ assertTrue("equals", expLocation.equals(fExpLocation));
+ assertTrue("equals", fExpLocation.equals(expLocation));
+ }
+
+ @Test
+ public void testEqualsTransivity() {
+ TmfStringLocation location1 = new TmfStringLocation(aString);
+ TmfStringLocation location2 = new TmfStringLocation(aString);
+ TmfStringLocation location3 = new TmfStringLocation(aString);
+ TmfExperimentLocation expLocation1 = new TmfExperimentLocation(aLocationArray);
+ TmfExperimentLocation expLocation2 = new TmfExperimentLocation(aLocationArray);
+ TmfExperimentLocation expLocation3 = new TmfExperimentLocation(aLocationArray);
+
+ assertTrue("equals", location1.equals(location2));
+ assertTrue("equals", location2.equals(location3));
+ assertTrue("equals", location3.equals(location1));
+ assertTrue("equals", expLocation1.equals(expLocation2));
+ assertTrue("equals", expLocation2.equals(expLocation3));
+ assertTrue("equals", expLocation3.equals(expLocation1));
+ }
+
+ @Test
+ public void testEqualsNull() {
+ assertTrue("equals", !fLocation2.equals(null));
+ assertTrue("equals", !fLocation2.equals(null));
+ assertTrue("equals", !fExpLocation.equals(null));
+ }
+
+ // ------------------------------------------------------------------------
+ // toString
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testToString() {
+ String str = "some location";
+ Long lng = 12345L;
+ TmfTimestamp ts = new TmfTimestamp();
+
+ TmfStringLocation location1 = new TmfStringLocation(str);
+ TmfLongLocation location2 = new TmfLongLocation(lng);
+ TmfTimestampLocation location3 = new TmfTimestampLocation(ts);
+ TmfExperimentLocation expLocation = new TmfExperimentLocation(aLocationArray);
+
+ String expected1 = "TmfStringLocation [fLocationInfo=" + str + "]";
+ String expected2 = "TmfLongLocation [fLocationInfo=" + lng + "]";
+ String expected3 = "TmfTimestampLocation [fLocationInfo=" + ts + "]";
+ String expected4 = "TmfExperimentLocation [" + aLocationArray + "]";
+
+ assertEquals("toString", expected1, location1.toString());
+ assertEquals("toString", expected2, location2.toString());
+ assertEquals("toString", expected3, location3.toString());
+ assertEquals("toString", expected4, expLocation.toString());
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.location;
+
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLocation;
+
+/**
+ * <b><u>TmfStringLocation</u></b>
+ * <p>
+ * Implement me. Please.
+ * <p>
+ */
+public class TmfStringLocation extends TmfLocation {
+
+ /**
+ * @param location the concrete trace location
+ */
+ public TmfStringLocation(String location) {
+ super(location);
+ }
+
+ /**
+ * @param other the other location
+ */
+ public TmfStringLocation(TmfStringLocation other) {
+ super(other.getLocationInfo());
+ }
+
+ @Override
+ public String getLocationInfo() {
+ return (String) super.getLocationInfo();
+ }
+
+}
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* <b><u>TmfEmptyTraceStub</u></b>
import java.util.List;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfCheckpoint;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint;
/**
* <b><u>TmfIndexerStub</u></b>
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.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
/**
* <b><u>TmfTraceStub</u></b>
org.eclipse.linuxtools.tmf.core.statistics,
org.eclipse.linuxtools.tmf.core.timestamp,
org.eclipse.linuxtools.tmf.core.trace,
+ org.eclipse.linuxtools.tmf.core.trace.indexer,
+ org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint,
+ org.eclipse.linuxtools.tmf.core.trace.location,
org.eclipse.linuxtools.tmf.core.uml2sd,
org.eclipse.linuxtools.tmf.core.util
package org.eclipse.linuxtools.internal.tmf.core.trace;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
import java.util.Arrays;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader;
import org.eclipse.linuxtools.ctf.core.trace.StreamInputReader;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* The CTF trace reader iterator.
/**
* Method setLocation.
* @param location ITmfLocation<?>
+ * @since 3.0
*/
@Override
public void setLocation(final ITmfLocation location) {
package org.eclipse.linuxtools.tmf.core.ctfadaptor;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLocation;
/**
* The nugget of information that is unique to a location in a CTF trace.
package org.eclipse.linuxtools.tmf.core.ctfadaptor;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* Lightweight Context for CtfTmf traces. Should only use 3 references, 1 ref to
return curRank;
}
+ /**
+ * @since 3.0
+ */
@Override
public ITmfLocation getLocation() {
return curLocation;
return curRank != CtfLocation.INVALID_LOCATION.getTimestamp();
}
+ /**
+ * @since 3.0
+ */
@Override
public void setLocation(ITmfLocation location) {
curLocation = (CtfLocation) location;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceProperties;
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* The CTf trace handler
*
* @return null, since the trace has no knowledge of the current location
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getCurrentLocation()
+ * @since 3.0
*/
@Override
public ITmfLocation getCurrentLocation() {
return null;
}
+ /**
+ * @since 3.0
+ */
@Override
public double getLocationRatio(ITmfLocation location) {
final CtfLocation curLocation = (CtfLocation) location;
* @param location
* ITmfLocation<?>
* @return ITmfContext
+ * @since 3.0
*/
@Override
public synchronized ITmfContext seekEvent(final ITmfLocation location) {
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Patrick Tasse - Updated for location in checkpoint
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-
-/**
- * The basic trace checkpoint structure in TMF. The purpose of the checkpoint is
- * to associate a trace location to an event timestamp.
- *
- * @version 1.0
- * @author Francois Chouinard
- *
- * @see ITmfTimestamp
- * @see ITmfLocation
- */
-public interface ITmfCheckpoint extends Comparable<ITmfCheckpoint> {
-
- // ------------------------------------------------------------------------
- // Getters
- // ------------------------------------------------------------------------
-
- /**
- * @return the timestamp of the event referred to by the context
- * @since 2.0
- */
- ITmfTimestamp getTimestamp();
-
- /**
- * @return the location of the event referred to by the checkpoint
- */
- ITmfLocation getLocation();
-
- // ------------------------------------------------------------------------
- // Comparable
- // ------------------------------------------------------------------------
-
- @Override
- int compareTo(ITmfCheckpoint checkpoint);
-
-}
package org.eclipse.linuxtools.tmf.core.trace;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+
/**
* The basic trace context structure in TMF. The purpose of the context is to
* associate a trace location to an event at a specific rank (order).
/**
* @return the location of the event at the context rank
+ * @since 3.0
*/
ITmfLocation getLocation();
/**
* @param location the new location
+ * @since 3.0
*/
void setLocation(ITmfLocation location);
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Francois Chouinard - Updated as per TMF Trace Model 1.0
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-/**
- * The generic trace location in TMF.
- * <p>
- * An ITmfLocation is the equivalent of a random-access file position, holding
- * enough information to allow the positioning of the trace 'pointer' to read an
- * arbitrary event.
- * <p>
- * This location is trace-specific, must be comparable and immutable.
- *
- * @version 2.0
- * @author Francois Chouinard
- */
-public interface ITmfLocation {
-
- // ------------------------------------------------------------------------
- // Getters
- // ------------------------------------------------------------------------
-
- /**
- * Returns the concrete trace location information
- *
- * @return the location information
- * @since 2.0
- */
- Comparable<?> getLocationInfo();
-
-}
import org.eclipse.linuxtools.tmf.core.statistics.ITmfStatistics;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* The event stream structure in TMF. In its basic form, a trace has:
/**
* @return the current trace location
+ * @since 3.0
*/
ITmfLocation getCurrentLocation();
*
* @param location a trace specific location
* @return a floating-point number between 0.0 (beginning) and 1.0 (end)
+ * @since 3.0
*/
double getLocationRatio(ITmfLocation location);
* <p>
* @param location the trace specific location
* @return a context which can later be used to read the corresponding event
+ * @since 3.0
*/
ITmfContext seekEvent(ITmfLocation location);
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-
-/**
- * The generic trace indexer in TMF with support for incremental indexing.
- *
- * @version 1.0
- * @author Francois Chouinard
- *
- * @see ITmfTrace
- * @see ITmfEvent
- */
-public interface ITmfTraceIndexer {
-
- /**
- * Start an asynchronous index building job and waits for the job completion
- * if required. Typically, the indexing job sends notifications at regular
- * intervals to indicate its progress.
- * <p>
- * <b>Example 1</b>: Index a whole trace asynchronously
- *
- * <pre>
- * trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, false);
- * </pre>
- *
- * <b>Example 2</b>: Index a whole trace synchronously
- *
- * <pre>
- * trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
- * </pre>
- *
- * <b>Example 3</b>: Index a trace asynchronously, starting at rank 100
- *
- * <pre>
- * trace.getIndexer().buildIndex(100, TmfTimeRange.ETERNITY, false);
- * </pre>
- *
- * <b>Example 4</b>: Index a trace asynchronously, starting at rank 100 for
- * events between T1 and T2 (inclusive). This is used for incremental
- * indexing.
- *
- * <pre>
- * TmfTimeRange range = new TmfTimeRange(T1, T2);
- * trace.getIndexer().buildIndex(100, range, false);
- * </pre>
- *
- * @param offset
- * The offset of the first event to consider
- * @param range
- * The time range to consider
- * @param waitForCompletion
- * Should we block the calling thread until the build is
- * complete?
- * @since 2.0
- */
- void buildIndex(long offset, TmfTimeRange range, boolean waitForCompletion);
-
- /**
- * Indicates that the indexer is busy indexing the trace.
- * Will always return false if the indexing is done synchronously.
- *
- * @return the state of the indexer (indexing or not)
- */
- boolean isIndexing();
-
- /**
- * Adds an entry to the trace index.
- *
- * @param context The trace context to save
- * @param timestamp The timestamp matching this context
- * @since 2.0
- */
- void updateIndex(ITmfContext context, ITmfTimestamp timestamp);
-
- /**
- * Returns the context of the checkpoint immediately preceding the requested
- * timestamp (or at the timestamp if it coincides with a checkpoint).
- *
- * @param timestamp the requested timestamp
- * @return the checkpoint context
- * @since 2.0
- */
- ITmfContext seekIndex(ITmfTimestamp timestamp);
-
- /**
- * Returns the context of the checkpoint immediately preceding the requested
- * rank (or at rank if it coincides with a checkpoint).
- *
- * @param rank the requested event rank
- * @return the checkpoint context
- */
- ITmfContext seekIndex(long rank);
-
- /**
- * Perform cleanup when the indexer is no longer required.
- */
- void dispose();
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Francois Chouinard - Updated as per TMF Trace Model 1.0
- * Patrick Tasse - Updated for location in checkpoint
- ******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-
-/**
- * A basic implementation of ITmfCheckpoint. It simply maps an event timestamp
- * to a generic location.
- *
- * @version 1.0
- * @author Francois Chouinard
- *
- * @see ITmfLocation
- * @see ITmfTimestamp
- */
-public class TmfCheckpoint implements ITmfCheckpoint {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- // The checkpoint location
- private final ITmfLocation fLocation;
-
- // The checkpoint timestamp
- private final ITmfTimestamp fTimestamp;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Full constructor
- *
- * @param timestamp the checkpoint timestamp
- * @param location the corresponding trace location
- * @since 2.0
- */
- public TmfCheckpoint(final ITmfTimestamp timestamp, final ITmfLocation location) {
- fTimestamp = timestamp;
- fLocation = location;
- }
-
- /**
- * Copy constructor
- *
- * @param other the other checkpoint
- */
- public TmfCheckpoint(final TmfCheckpoint other) {
- if (other == null) {
- throw new IllegalArgumentException();
- }
- fTimestamp = other.fTimestamp;
- fLocation = other.fLocation;
- }
-
- // ------------------------------------------------------------------------
- // ITmfCheckpoint
- // ------------------------------------------------------------------------
-
- /**
- * @since 2.0
- */
- @Override
- public ITmfTimestamp getTimestamp() {
- return fTimestamp;
- }
-
- @Override
- public ITmfLocation getLocation() {
- return fLocation;
- }
-
- // ------------------------------------------------------------------------
- // Comparable
- // ------------------------------------------------------------------------
-
- @Override
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public int compareTo(final ITmfCheckpoint other) {
- int comp = 0;
- if ((fTimestamp != null) && (other.getTimestamp() != null)) {
- comp = fTimestamp.compareTo(other.getTimestamp(), false);
- if (comp != 0) {
- return comp;
- }
- // compare locations if timestamps are the same
- }
-
- if ((fLocation == null) && (other.getLocation() == null)) {
- return 0;
- }
-
- // treat location of other as null location which is before any location
- if ((fLocation != null) && (other.getLocation() == null)) {
- return 1;
- }
-
- // treat this as null location which is before any other locations
- if ((fLocation == null) && (other.getLocation() != null)) {
- return -1;
- }
-
- // compare location
- final Comparable location1 = getLocation().getLocationInfo();
- final Comparable location2 = other.getLocation().getLocationInfo();
- return location1.compareTo(location2);
- }
-
- // ------------------------------------------------------------------------
- // Object
- // ------------------------------------------------------------------------
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((fLocation == null) ? 0 : fLocation.hashCode());
- result = prime * result + ((fTimestamp == null) ? 0 : fTimestamp.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof TmfCheckpoint)) {
- return false;
- }
- final TmfCheckpoint other = (TmfCheckpoint) obj;
- if (fLocation == null) {
- if (other.fLocation != null) {
- return false;
- }
- } else if (!fLocation.equals(other.fLocation)) {
- return false;
- }
- if (fTimestamp == null) {
- if (other.fTimestamp != null) {
- return false;
- }
- } else if (!fTimestamp.equals(other.fTimestamp)) {
- return false;
- }
- return true;
- }
-
- @Override
- @SuppressWarnings("nls")
- public String toString() {
- return getClass().getSimpleName() + " [fLocation=" + fLocation + ", fTimestamp=" + fTimestamp + "]";
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.linuxtools.internal.tmf.core.Messages;
-import org.eclipse.linuxtools.tmf.core.component.TmfDataProvider;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
-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.TmfTraceUpdatedSignal;
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-
-/**
- * A simple indexer that manages the trace index as an array of trace
- * checkpoints. Checkpoints are stored at fixed intervals (event rank) in
- * ascending timestamp order.
- * <p>
- * The goal being to access a random trace event reasonably fast from the user's
- * standpoint, picking the right interval value becomes a trade-off between speed
- * and memory usage (a shorter inter-event interval is faster but requires more
- * checkpoints).
- * <p>
- * Locating a specific checkpoint is trivial for both rank (rank % interval) and
- * timestamp (bsearch in the array).
- *
- * @version 1.0
- * @author Francois Chouinard
- *
- * @see ITmfTrace
- * @see ITmfEvent
- */
-public class TmfCheckpointIndexer implements ITmfTraceIndexer {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- /** The event trace to index */
- protected final ITmfTrace fTrace;
-
- /** The interval between checkpoints */
- private final int fCheckpointInterval;
-
- /** The event trace to index */
- private boolean fIsIndexing;
-
- /**
- * The trace index. It is composed of checkpoints taken at intervals of
- * fCheckpointInterval events.
- */
- protected final List<ITmfCheckpoint> fTraceIndex;
-
- /**
- * The indexing request
- */
- private ITmfEventRequest fIndexingRequest = null;
-
- // ------------------------------------------------------------------------
- // Construction
- // ------------------------------------------------------------------------
-
- /**
- * Basic constructor that uses the default trace block size as checkpoints
- * intervals
- *
- * @param trace the trace to index
- */
- public TmfCheckpointIndexer(final ITmfTrace trace) {
- this(trace, TmfDataProvider.DEFAULT_BLOCK_SIZE);
- }
-
- /**
- * Full trace indexer
- *
- * @param trace the trace to index
- * @param interval the checkpoints interval
- */
- public TmfCheckpointIndexer(final ITmfTrace trace, final int interval) {
- fTrace = trace;
- fCheckpointInterval = interval;
- fTraceIndex = new ArrayList<ITmfCheckpoint>();
- fIsIndexing = false;
- }
-
- @Override
- public void dispose() {
- if ((fIndexingRequest != null) && !fIndexingRequest.isCompleted()) {
- fIndexingRequest.cancel();
- fTraceIndex.clear();
- }
- }
-
- // ------------------------------------------------------------------------
- // ITmfTraceIndexer - isIndexing
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isIndexing() {
- return fIsIndexing;
- }
-
- // ------------------------------------------------------------------------
- // ITmfTraceIndexer - buildIndex
- // ------------------------------------------------------------------------
-
- /**
- * @since 2.0
- */
- @Override
- public void buildIndex(final long offset, final TmfTimeRange range, final boolean waitForCompletion) {
-
- // Don't do anything if we are already indexing
- synchronized (fTraceIndex) {
- if (fIsIndexing) {
- return;
- }
- fIsIndexing = true;
- }
-
- // The monitoring job
- final Job job = new Job("Indexing " + fTrace.getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$
- @Override
- protected IStatus run(final IProgressMonitor monitor) {
- monitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
- while (!monitor.isCanceled()) {
- try {
- long prevNbEvents = fTrace.getNbEvents();
- Thread.sleep(250);
- long nbEvents = fTrace.getNbEvents();
- setName(Messages.TmfCheckpointIndexer_Indexing + ' ' + fTrace.getName() + " (" + nbEvents + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- // setName doesn't refresh the UI, setTaskName does
- long rate = (nbEvents - prevNbEvents) * 4;
- monitor.setTaskName(rate + " " + Messages.TmfCheckpointIndexer_EventsPerSecond); //$NON-NLS-1$
- } catch (final InterruptedException e) {
- return Status.OK_STATUS;
- }
- }
- monitor.done();
- return Status.OK_STATUS;
- }
- };
- job.schedule();
-
- // Build a background request for all the trace data. The index is
- // updated as we go by readNextEvent().
- fIndexingRequest = new TmfEventRequest(ITmfEvent.class,
- range, offset, TmfDataRequest.ALL_DATA,
- ITmfDataRequest.ExecutionType.BACKGROUND) {
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- if (event != null) {
- // Update the trace status at regular intervals
- if ((getNbRead() % fCheckpointInterval) == 0) {
- updateTraceStatus();
- }
- }
- }
-
- @Override
- public void handleSuccess() {
- updateTraceStatus();
- }
-
- @Override
- public void handleCompleted() {
- job.cancel();
- super.handleCompleted();
- fIsIndexing = false;
- }
-
- private void updateTraceStatus() {
- if (fTrace.getNbEvents() > 0) {
- signalNewTimeRange(fTrace.getStartTime(), fTrace.getEndTime());
- }
- }
- };
-
- // Submit the request and wait for completion if required
- fTrace.sendRequest(fIndexingRequest);
- if (waitForCompletion) {
- try {
- fIndexingRequest.waitForCompletion();
- } catch (final InterruptedException e) {
- }
- }
- }
-
- /**
- * Notify the interested parties that the trace time range has changed
- *
- * @param startTime the new start time
- * @param endTime the new end time
- */
- private void signalNewTimeRange(final ITmfTimestamp startTime, final ITmfTimestamp endTime) {
- fTrace.broadcast(new TmfTraceUpdatedSignal(fTrace, fTrace, new TmfTimeRange(startTime, endTime)));
- }
-
- // ------------------------------------------------------------------------
- // ITmfTraceIndexer - updateIndex
- // ------------------------------------------------------------------------
-
- /**
- * @since 2.0
- */
- @Override
- public synchronized void updateIndex(final ITmfContext context, final ITmfTimestamp timestamp) {
- if ((context.getRank() % fCheckpointInterval) == 0) {
- // Determine the table position
- final long position = context.getRank() / fCheckpointInterval;
- // Add new entry at proper location (if empty)
- if (fTraceIndex.size() == position) {
- fTraceIndex.add(new TmfCheckpoint(timestamp, context.getLocation()));
- }
- }
- }
-
- // ------------------------------------------------------------------------
- // ITmfTraceIndexer - seekIndex
- // ------------------------------------------------------------------------
-
- /**
- * @since 2.0
- */
- @Override
- public synchronized ITmfContext seekIndex(final ITmfTimestamp timestamp) {
-
- // A null timestamp indicates to seek the first event
- if (timestamp == null) {
- return fTrace.seekEvent(0);
- }
-
- // Find the checkpoint at or before the requested timestamp.
- // In the very likely event that the timestamp is not at a checkpoint
- // boundary, bsearch will return index = (- (insertion point + 1)).
- // It is then trivial to compute the index of the previous checkpoint.
- int index = Collections.binarySearch(fTraceIndex, new TmfCheckpoint(timestamp, null));
- if (index < 0) {
- index = Math.max(0, -(index + 2));
- } else {
- // If timestamp was in the list, use previous index to be able to find the
- // first event with the same timestamp before the checkpoint
- index = Math.max(0, index - 1);
- }
-
- // Position the trace at the checkpoint
- return restoreCheckpoint(index);
- }
-
- @Override
- public ITmfContext seekIndex(final long rank) {
-
- // A rank < 0 indicates to seek the first event
- if (rank < 0) {
- return fTrace.seekEvent(0);
- }
-
- // Find the checkpoint at or before the requested rank.
- final int index = (int) rank / fCheckpointInterval;
-
- // Position the trace at the checkpoint
- return restoreCheckpoint(index);
- }
-
- /**
- * Position the trace at the given checkpoint
- *
- * @param checkpoint the checkpoint index
- * @return the corresponding context
- */
- private ITmfContext restoreCheckpoint(final int checkpoint) {
- ITmfLocation location = null;
- int index = 0;
- synchronized (fTraceIndex) {
- if (!fTraceIndex.isEmpty()) {
- index = checkpoint;
- if (index >= fTraceIndex.size()) {
- index = fTraceIndex.size() - 1;
- }
- location = fTraceIndex.get(index).getLocation();
- }
- }
- final ITmfContext context = fTrace.seekEvent(location);
- context.setRank((long) index * fCheckpointInterval);
- return context;
- }
-
- // ------------------------------------------------------------------------
- // Getters
- // ------------------------------------------------------------------------
-
- /**
- * @return the trace index
- */
- protected List<ITmfCheckpoint> getTraceIndex() {
- return fTraceIndex;
- }
-
-}
package org.eclipse.linuxtools.tmf.core.trace;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+
/**
* A basic implementation of ITmfContext.
* <p>
* Simple constructor (unknown rank)
*
* @param location the event location
+ * @since 3.0
*/
public TmfContext(final ITmfLocation location) {
this(location, UNKNOWN_RANK);
*
* @param location the event location
* @param rank the event rank
+ * @since 3.0
*/
public TmfContext(final ITmfLocation location, final long rank) {
fLocation = location;
// ITmfContext
// ------------------------------------------------------------------------
+ /**
+ * @since 3.0
+ */
@Override
public ITmfLocation getLocation() {
return fLocation;
}
+ /**
+ * @since 3.0
+ */
@Override
public void setLocation(final ITmfLocation location) {
fLocation = location;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* TmfExperiment presents a time-ordered, unified view of a set of ITmfTrace:s
// ITmfTrace trace positioning
// ------------------------------------------------------------------------
+ /**
+ * @since 3.0
+ */
@Override
public synchronized ITmfContext seekEvent(final ITmfLocation location) {
// Validate the location
return context;
}
+ /**
+ * @since 3.0
+ */
@Override
public double getLocationRatio(final ITmfLocation location) {
if (location instanceof TmfExperimentLocation) {
return 0.0;
}
+ /**
+ * @since 3.0
+ */
@Override
public ITmfLocation getCurrentLocation() {
// never used
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Francois Chouinard - Updated as per TMF Trace Model 1.0
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-
-/**
- * A abstract implementation of ITmfLocation. The concrete classes must provide
- * comparable location information.
- *
- * @version 2.0
- * @author Francois Chouinard
- */
-public abstract class TmfLocation implements ITmfLocation {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final Comparable<?> fLocationInfo;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Standard constructor.
- *
- * @param locationInfo
- * The concrete trace location
- */
- public TmfLocation(final Comparable<?> locationInfo) {
- fLocationInfo = locationInfo;
- }
-
- /**
- * Copy constructor
- *
- * @param location
- * The original trace location
- */
- public TmfLocation(final TmfLocation location) {
- fLocationInfo = location.fLocationInfo;
- }
-
- // ------------------------------------------------------------------------
- // Getters
- // ------------------------------------------------------------------------
-
- /**
- * @since 2.0
- */
- @Override
- public Comparable<?> getLocationInfo() {
- return fLocationInfo;
- }
-
- // ------------------------------------------------------------------------
- // Object
- // ------------------------------------------------------------------------
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((fLocationInfo != null) ? fLocationInfo.hashCode() : 0);
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final TmfLocation other = (TmfLocation) obj;
- if (fLocationInfo == null) {
- if (other.fLocationInfo != null) {
- return false;
- }
- } else if (!fLocationInfo.equals(other.fLocationInfo)) {
- return false;
- }
- return true;
- }
-
- @Override
- @SuppressWarnings("nls")
- public String toString() {
- return getClass().getSimpleName() + " [fLocationInfo=" + fLocationInfo + "]";
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-/**
- * A concrete implementation of TmfLocation based on Long:s
- *
- * @author Francois Chouinard
- * @since 2.0
- */
-public final class TmfLongLocation extends TmfLocation {
-
- /**
- * The normal constructor
- *
- * @param locationInfo the concrete location
- */
- public TmfLongLocation(final Long locationInfo) {
- super(locationInfo);
- }
-
- /**
- * The copy constructor
- *
- * @param other the other location
- */
- public TmfLongLocation(final TmfLongLocation other) {
- super(other.getLocationInfo());
- }
-
- @Override
- public Long getLocationInfo() {
- return (Long) super.getLocationInfo();
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-
-/**
- * A concrete implementation of TmfLocation based on ITmfTimestamp:s
- *
- * @author Francois Chouinard
- * @since 2.0
- */
-public final class TmfTimestampLocation extends TmfLocation {
-
- /**
- * The normal constructor
- *
- * @param locationInfo the concrete location
- */
- public TmfTimestampLocation(final ITmfTimestamp locationInfo) {
- super(locationInfo);
- }
-
- /**
- * The copy constructor
- *
- * @param other the other location
- */
- public TmfTimestampLocation(final TmfTimestampLocation other) {
- super(other.getLocationInfo());
- }
-
- @Override
- public ITmfTimestamp getLocationInfo() {
- return (ITmfTimestamp) super.getLocationInfo();
- }
-
-}
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* Abstract implementation of ITmfTrace.
/**
* @return the trace indexer
+ * @since 3.0
*/
protected ITmfTraceIndexer getIndexer() {
return fIndexer;
* Set the trace indexer. Must be done at initialization time.
*
* @param indexer the trace indexer
+ * @since 3.0
*/
protected void setIndexer(final ITmfTraceIndexer indexer) {
fIndexer = indexer;
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.indexer;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * The generic trace indexer in TMF with support for incremental indexing.
+ *
+ * @see ITmfTrace
+ * @see ITmfEvent
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public interface ITmfTraceIndexer {
+
+ /**
+ * Start an asynchronous index building job and waits for the job completion
+ * if required. Typically, the indexing job sends notifications at regular
+ * intervals to indicate its progress.
+ * <p>
+ * <b>Example 1</b>: Index a whole trace asynchronously
+ *
+ * <pre>
+ * trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, false);
+ * </pre>
+ *
+ * <b>Example 2</b>: Index a whole trace synchronously
+ *
+ * <pre>
+ * trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
+ * </pre>
+ *
+ * <b>Example 3</b>: Index a trace asynchronously, starting at rank 100
+ *
+ * <pre>
+ * trace.getIndexer().buildIndex(100, TmfTimeRange.ETERNITY, false);
+ * </pre>
+ *
+ * <b>Example 4</b>: Index a trace asynchronously, starting at rank 100 for
+ * events between T1 and T2 (inclusive). This is used for incremental
+ * indexing.
+ *
+ * <pre>
+ * TmfTimeRange range = new TmfTimeRange(T1, T2);
+ * trace.getIndexer().buildIndex(100, range, false);
+ * </pre>
+ *
+ * @param offset
+ * The offset of the first event to consider
+ * @param range
+ * The time range to consider
+ * @param waitForCompletion
+ * Should we block the calling thread until the build is
+ * complete?
+ * @since 2.0
+ */
+ void buildIndex(long offset, TmfTimeRange range, boolean waitForCompletion);
+
+ /**
+ * Indicates that the indexer is busy indexing the trace.
+ * Will always return false if the indexing is done synchronously.
+ *
+ * @return the state of the indexer (indexing or not)
+ */
+ boolean isIndexing();
+
+ /**
+ * Adds an entry to the trace index.
+ *
+ * @param context The trace context to save
+ * @param timestamp The timestamp matching this context
+ * @since 2.0
+ */
+ void updateIndex(ITmfContext context, ITmfTimestamp timestamp);
+
+ /**
+ * Returns the context of the checkpoint immediately preceding the requested
+ * timestamp (or at the timestamp if it coincides with a checkpoint).
+ *
+ * @param timestamp the requested timestamp
+ * @return the checkpoint context
+ * @since 2.0
+ */
+ ITmfContext seekIndex(ITmfTimestamp timestamp);
+
+ /**
+ * Returns the context of the checkpoint immediately preceding the requested
+ * rank (or at rank if it coincides with a checkpoint).
+ *
+ * @param rank the requested event rank
+ * @return the checkpoint context
+ */
+ ITmfContext seekIndex(long rank);
+
+ /**
+ * Perform cleanup when the indexer is no longer required.
+ */
+ void dispose();
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Patrick Tasse - Updated for location in checkpoint
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint;
+
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+
+/**
+ * The basic trace checkpoint structure in TMF. The purpose of the checkpoint is
+ * to associate a trace location to an event timestamp.
+ * *
+ * @see ITmfTimestamp
+ * @see ITmfLocation
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public interface ITmfCheckpoint extends Comparable<ITmfCheckpoint> {
+
+ // ------------------------------------------------------------------------
+ // Getters
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return the timestamp of the event referred to by the context
+ * @since 2.0
+ */
+ ITmfTimestamp getTimestamp();
+
+ /**
+ * @return the location of the event referred to by the checkpoint
+ */
+ ITmfLocation getLocation();
+
+ // ------------------------------------------------------------------------
+ // Comparable
+ // ------------------------------------------------------------------------
+
+ @Override
+ int compareTo(ITmfCheckpoint checkpoint);
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Updated as per TMF Trace Model 1.0
+ * Patrick Tasse - Updated for location in checkpoint
+ ******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint;
+
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+
+/**
+ * A basic implementation of ITmfCheckpoint. It simply maps an event timestamp
+ * to a generic location.
+ *
+ * @see ITmfLocation
+ * @see ITmfTimestamp
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public class TmfCheckpoint implements ITmfCheckpoint {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ // The checkpoint location
+ private final ITmfLocation fLocation;
+
+ // The checkpoint timestamp
+ private final ITmfTimestamp fTimestamp;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Full constructor
+ *
+ * @param timestamp the checkpoint timestamp
+ * @param location the corresponding trace location
+ * @since 3.0
+ */
+ public TmfCheckpoint(final ITmfTimestamp timestamp, final ITmfLocation location) {
+ fTimestamp = timestamp;
+ fLocation = location;
+ }
+
+ /**
+ * Copy constructor
+ *
+ * @param other the other checkpoint
+ */
+ public TmfCheckpoint(final TmfCheckpoint other) {
+ if (other == null) {
+ throw new IllegalArgumentException();
+ }
+ fTimestamp = other.fTimestamp;
+ fLocation = other.fLocation;
+ }
+
+ // ------------------------------------------------------------------------
+ // ITmfCheckpoint
+ // ------------------------------------------------------------------------
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public ITmfTimestamp getTimestamp() {
+ return fTimestamp;
+ }
+
+ @Override
+ public ITmfLocation getLocation() {
+ return fLocation;
+ }
+
+ // ------------------------------------------------------------------------
+ // Comparable
+ // ------------------------------------------------------------------------
+
+ @Override
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public int compareTo(final ITmfCheckpoint other) {
+ int comp = 0;
+ if ((fTimestamp != null) && (other.getTimestamp() != null)) {
+ comp = fTimestamp.compareTo(other.getTimestamp(), false);
+ if (comp != 0) {
+ return comp;
+ }
+ // compare locations if timestamps are the same
+ }
+
+ if ((fLocation == null) && (other.getLocation() == null)) {
+ return 0;
+ }
+
+ // treat location of other as null location which is before any location
+ if ((fLocation != null) && (other.getLocation() == null)) {
+ return 1;
+ }
+
+ // treat this as null location which is before any other locations
+ if ((fLocation == null) && (other.getLocation() != null)) {
+ return -1;
+ }
+
+ // compare location
+ final Comparable location1 = getLocation().getLocationInfo();
+ final Comparable location2 = other.getLocation().getLocationInfo();
+ return location1.compareTo(location2);
+ }
+
+ // ------------------------------------------------------------------------
+ // Object
+ // ------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((fLocation == null) ? 0 : fLocation.hashCode());
+ result = prime * result + ((fTimestamp == null) ? 0 : fTimestamp.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj instanceof TmfCheckpoint)) {
+ return false;
+ }
+ final TmfCheckpoint other = (TmfCheckpoint) obj;
+ if (fLocation == null) {
+ if (other.fLocation != null) {
+ return false;
+ }
+ } else if (!fLocation.equals(other.fLocation)) {
+ return false;
+ }
+ if (fTimestamp == null) {
+ if (other.fTimestamp != null) {
+ return false;
+ }
+ } else if (!fTimestamp.equals(other.fTimestamp)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ @SuppressWarnings("nls")
+ public String toString() {
+ return getClass().getSimpleName() + " [fLocation=" + fLocation + ", fTimestamp=" + fTimestamp + "]";
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.linuxtools.internal.tmf.core.Messages;
+import org.eclipse.linuxtools.tmf.core.component.TmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
+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.TmfTraceUpdatedSignal;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+
+/**
+ * A simple indexer that manages the trace index as an array of trace
+ * checkpoints. Checkpoints are stored at fixed intervals (event rank) in
+ * ascending timestamp order.
+ * <p>
+ * The goal being to access a random trace event reasonably fast from the user's
+ * standpoint, picking the right interval value becomes a trade-off between speed
+ * and memory usage (a shorter inter-event interval is faster but requires more
+ * checkpoints).
+ * <p>
+ * Locating a specific checkpoint is trivial for both rank (rank % interval) and
+ * timestamp (bsearch in the array).
+ * *
+ * @see ITmfTrace
+ * @see ITmfEvent
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public class TmfCheckpointIndexer implements ITmfTraceIndexer {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /** The event trace to index */
+ protected final ITmfTrace fTrace;
+
+ /** The interval between checkpoints */
+ private final int fCheckpointInterval;
+
+ /** The event trace to index */
+ private boolean fIsIndexing;
+
+ /**
+ * The trace index. It is composed of checkpoints taken at intervals of
+ * fCheckpointInterval events.
+ */
+ protected final List<ITmfCheckpoint> fTraceIndex;
+
+ /**
+ * The indexing request
+ */
+ private ITmfEventRequest fIndexingRequest = null;
+
+ // ------------------------------------------------------------------------
+ // Construction
+ // ------------------------------------------------------------------------
+
+ /**
+ * Basic constructor that uses the default trace block size as checkpoints
+ * intervals
+ *
+ * @param trace the trace to index
+ */
+ public TmfCheckpointIndexer(final ITmfTrace trace) {
+ this(trace, TmfDataProvider.DEFAULT_BLOCK_SIZE);
+ }
+
+ /**
+ * Full trace indexer
+ *
+ * @param trace the trace to index
+ * @param interval the checkpoints interval
+ */
+ public TmfCheckpointIndexer(final ITmfTrace trace, final int interval) {
+ fTrace = trace;
+ fCheckpointInterval = interval;
+ fTraceIndex = new ArrayList<ITmfCheckpoint>();
+ fIsIndexing = false;
+ }
+
+ @Override
+ public void dispose() {
+ if ((fIndexingRequest != null) && !fIndexingRequest.isCompleted()) {
+ fIndexingRequest.cancel();
+ fTraceIndex.clear();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // ITmfTraceIndexer - isIndexing
+ // ------------------------------------------------------------------------
+
+ @Override
+ public boolean isIndexing() {
+ return fIsIndexing;
+ }
+
+ // ------------------------------------------------------------------------
+ // ITmfTraceIndexer - buildIndex
+ // ------------------------------------------------------------------------
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public void buildIndex(final long offset, final TmfTimeRange range, final boolean waitForCompletion) {
+
+ // Don't do anything if we are already indexing
+ synchronized (fTraceIndex) {
+ if (fIsIndexing) {
+ return;
+ }
+ fIsIndexing = true;
+ }
+
+ // The monitoring job
+ final Job job = new Job("Indexing " + fTrace.getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$
+ @Override
+ protected IStatus run(final IProgressMonitor monitor) {
+ monitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+ while (!monitor.isCanceled()) {
+ try {
+ long prevNbEvents = fTrace.getNbEvents();
+ Thread.sleep(250);
+ long nbEvents = fTrace.getNbEvents();
+ setName(Messages.TmfCheckpointIndexer_Indexing + ' ' + fTrace.getName() + " (" + nbEvents + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ // setName doesn't refresh the UI, setTaskName does
+ long rate = (nbEvents - prevNbEvents) * 4;
+ monitor.setTaskName(rate + " " + Messages.TmfCheckpointIndexer_EventsPerSecond); //$NON-NLS-1$
+ } catch (final InterruptedException e) {
+ return Status.OK_STATUS;
+ }
+ }
+ monitor.done();
+ return Status.OK_STATUS;
+ }
+ };
+ job.schedule();
+
+ // Build a background request for all the trace data. The index is
+ // updated as we go by readNextEvent().
+ fIndexingRequest = new TmfEventRequest(ITmfEvent.class,
+ range, offset, TmfDataRequest.ALL_DATA,
+ ITmfDataRequest.ExecutionType.BACKGROUND) {
+ @Override
+ public void handleData(final ITmfEvent event) {
+ super.handleData(event);
+ if (event != null) {
+ // Update the trace status at regular intervals
+ if ((getNbRead() % fCheckpointInterval) == 0) {
+ updateTraceStatus();
+ }
+ }
+ }
+
+ @Override
+ public void handleSuccess() {
+ updateTraceStatus();
+ }
+
+ @Override
+ public void handleCompleted() {
+ job.cancel();
+ super.handleCompleted();
+ fIsIndexing = false;
+ }
+
+ private void updateTraceStatus() {
+ if (fTrace.getNbEvents() > 0) {
+ signalNewTimeRange(fTrace.getStartTime(), fTrace.getEndTime());
+ }
+ }
+ };
+
+ // Submit the request and wait for completion if required
+ fTrace.sendRequest(fIndexingRequest);
+ if (waitForCompletion) {
+ try {
+ fIndexingRequest.waitForCompletion();
+ } catch (final InterruptedException e) {
+ }
+ }
+ }
+
+ /**
+ * Notify the interested parties that the trace time range has changed
+ *
+ * @param startTime the new start time
+ * @param endTime the new end time
+ */
+ private void signalNewTimeRange(final ITmfTimestamp startTime, final ITmfTimestamp endTime) {
+ fTrace.broadcast(new TmfTraceUpdatedSignal(fTrace, fTrace, new TmfTimeRange(startTime, endTime)));
+ }
+
+ // ------------------------------------------------------------------------
+ // ITmfTraceIndexer - updateIndex
+ // ------------------------------------------------------------------------
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public synchronized void updateIndex(final ITmfContext context, final ITmfTimestamp timestamp) {
+ if ((context.getRank() % fCheckpointInterval) == 0) {
+ // Determine the table position
+ final long position = context.getRank() / fCheckpointInterval;
+ // Add new entry at proper location (if empty)
+ if (fTraceIndex.size() == position) {
+ fTraceIndex.add(new TmfCheckpoint(timestamp, context.getLocation()));
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // ITmfTraceIndexer - seekIndex
+ // ------------------------------------------------------------------------
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public synchronized ITmfContext seekIndex(final ITmfTimestamp timestamp) {
+
+ // A null timestamp indicates to seek the first event
+ if (timestamp == null) {
+ return fTrace.seekEvent(0);
+ }
+
+ // Find the checkpoint at or before the requested timestamp.
+ // In the very likely event that the timestamp is not at a checkpoint
+ // boundary, bsearch will return index = (- (insertion point + 1)).
+ // It is then trivial to compute the index of the previous checkpoint.
+ int index = Collections.binarySearch(fTraceIndex, new TmfCheckpoint(timestamp, null));
+ if (index < 0) {
+ index = Math.max(0, -(index + 2));
+ } else {
+ // If timestamp was in the list, use previous index to be able to find the
+ // first event with the same timestamp before the checkpoint
+ index = Math.max(0, index - 1);
+ }
+
+ // Position the trace at the checkpoint
+ return restoreCheckpoint(index);
+ }
+
+ @Override
+ public ITmfContext seekIndex(final long rank) {
+
+ // A rank < 0 indicates to seek the first event
+ if (rank < 0) {
+ return fTrace.seekEvent(0);
+ }
+
+ // Find the checkpoint at or before the requested rank.
+ final int index = (int) rank / fCheckpointInterval;
+
+ // Position the trace at the checkpoint
+ return restoreCheckpoint(index);
+ }
+
+ /**
+ * Position the trace at the given checkpoint
+ *
+ * @param checkpoint the checkpoint index
+ * @return the corresponding context
+ */
+ private ITmfContext restoreCheckpoint(final int checkpoint) {
+ ITmfLocation location = null;
+ int index = 0;
+ synchronized (fTraceIndex) {
+ if (!fTraceIndex.isEmpty()) {
+ index = checkpoint;
+ if (index >= fTraceIndex.size()) {
+ index = fTraceIndex.size() - 1;
+ }
+ location = fTraceIndex.get(index).getLocation();
+ }
+ }
+ final ITmfContext context = fTrace.seekEvent(location);
+ context.setRank((long) index * fCheckpointInterval);
+ return context;
+ }
+
+ // ------------------------------------------------------------------------
+ // Getters
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return the trace index
+ */
+ protected List<ITmfCheckpoint> getTraceIndex() {
+ return fTraceIndex;
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Updated as per TMF Trace Model 1.0
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.location;
+
+/**
+ * The generic trace location in TMF.
+ * <p>
+ * An ITmfLocation is the equivalent of a random-access file position, holding
+ * enough information to allow the positioning of the trace 'pointer' to read an
+ * arbitrary event.
+ * <p>
+ * This location is trace-specific, must be comparable and immutable.
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public interface ITmfLocation {
+
+ // ------------------------------------------------------------------------
+ // Getters
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns the concrete trace location information
+ *
+ * @return the location information
+ * @since 2.0
+ */
+ Comparable<?> getLocationInfo();
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Updated as per TMF Trace Model 1.0
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.location;
+
+
+/**
+ * A abstract implementation of ITmfLocation. The concrete classes must provide
+ * comparable location information.
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public abstract class TmfLocation implements ITmfLocation {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ private final Comparable<?> fLocationInfo;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Standard constructor.
+ *
+ * @param locationInfo
+ * The concrete trace location
+ */
+ public TmfLocation(final Comparable<?> locationInfo) {
+ fLocationInfo = locationInfo;
+ }
+
+ /**
+ * Copy constructor
+ *
+ * @param location
+ * The original trace location
+ */
+ public TmfLocation(final TmfLocation location) {
+ fLocationInfo = location.fLocationInfo;
+ }
+
+ // ------------------------------------------------------------------------
+ // Getters
+ // ------------------------------------------------------------------------
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public Comparable<?> getLocationInfo() {
+ return fLocationInfo;
+ }
+
+ // ------------------------------------------------------------------------
+ // Object
+ // ------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((fLocationInfo != null) ? fLocationInfo.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TmfLocation other = (TmfLocation) obj;
+ if (fLocationInfo == null) {
+ if (other.fLocationInfo != null) {
+ return false;
+ }
+ } else if (!fLocationInfo.equals(other.fLocationInfo)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ @SuppressWarnings("nls")
+ public String toString() {
+ return getClass().getSimpleName() + " [fLocationInfo=" + fLocationInfo + "]";
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.location;
+
+
+/**
+ * A concrete implementation of TmfLocation based on Long:s
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public final class TmfLongLocation extends TmfLocation {
+
+ /**
+ * The normal constructor
+ *
+ * @param locationInfo the concrete location
+ */
+ public TmfLongLocation(final Long locationInfo) {
+ super(locationInfo);
+ }
+
+ /**
+ * The copy constructor
+ *
+ * @param other the other location
+ */
+ public TmfLongLocation(final TmfLongLocation other) {
+ super(other.getLocationInfo());
+ }
+
+ @Override
+ public Long getLocationInfo() {
+ return (Long) super.getLocationInfo();
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.location;
+
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+
+/**
+ * A concrete implementation of TmfLocation based on ITmfTimestamp:s
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public final class TmfTimestampLocation extends TmfLocation {
+
+ /**
+ * The normal constructor
+ *
+ * @param locationInfo the concrete location
+ */
+ public TmfTimestampLocation(final ITmfTimestamp locationInfo) {
+ super(locationInfo);
+ }
+
+ /**
+ * The copy constructor
+ *
+ * @param other the other location
+ */
+ public TmfTimestampLocation(final TmfTimestampLocation other) {
+ super(other.getLocationInfo());
+ }
+
+ @Override
+ public ITmfTimestamp getLocationInfo() {
+ return (ITmfTimestamp) super.getLocationInfo();
+ }
+
+}
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
/**
* Base class for custom plain text traces.
import java.util.regex.Matcher;
import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* Trace context for custom text traces.
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.linuxtools.internal.tmf.ui.Activator;
import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputAttribute;
import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputElement;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* Trace context for custom XML traces.
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsCache.CachedEvent;
import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSetting;
import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CaretEvent;
import org.eclipse.swt.custom.CaretListener;