try {
testStream = null;
final LTTngTextTrace tmpStream = initializeEventStream();
- tmpEventContent = (LttngEventContent)tmpStream.getNextEvent( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent();
+ tmpEventContent = (LttngEventContent)tmpStream.readEvent( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent();
}
catch (final Exception e) {
fail("ERROR : Failed to get content!");
// Require an event
tmpStream = initializeEventStream();
tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
- tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
+ tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext);
testContent = prepareToTest();
// getFieldS()
assertNotSame("getFields() returned null!", null, testContent.getFields() );
// Skip first events and seek to event pass metadata
tmpContext= tmpStream.seekEvent(new LttngTimestamp(timestampAfterMetadata) );
// Skip first one
- tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
+ tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext);
// Second event past metadata should have more fields
- tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
+ tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext);
// Get the content
testContent = tmpEvent.getContent();
// Require an event
tmpStream = initializeEventStream();
tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
- tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
+ tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext);
final LttngEventContent tmpContent = prepareToTest();
try {
// Require an event
tmpStream = initializeEventStream();
tmpContext = new TmfContext(new TmfLocation<Long>(0L), 0);
- tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext);
+ tmpEvent = (LttngEvent)tmpStream.readEvent(tmpContext);
// Get the content
testContent = tmpEvent.getContent();
// Get all the fields to make sure there is something in the HashMap
// This trace should be valid
try {
final LTTngTextTrace tmpStream = initializeEventStream();
- tmpField = (LttngEventField)tmpStream.getNextEvent( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent().getField(0);
+ tmpField = (LttngEventField)tmpStream.readEvent( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent().getField(0);
}
catch (final Exception e) {
fail("ERROR : Failed to get field!");
LttngEventField testField = null;
// try {
- testField = (LttngEventField) tmpStream.getNextEvent( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent().getField(0);
+ testField = (LttngEventField) tmpStream.readEvent( new TmfContext(new TmfLocation<Long>(0L), 0) ).getContent().getField(0);
// } catch (TmfNoSuchFieldException e) {
// e.printStackTrace();
// }
try {
final LTTngTextTrace tmpStream = initializeEventStream();
- tmpEvent = (LttngEvent)tmpStream.getNextEvent(new TmfContext(new TmfLocation<Long>(0L), 0) );
+ tmpEvent = (LttngEvent)tmpStream.readEvent(new TmfContext(new TmfLocation<Long>(0L), 0) );
}
catch (final Exception e) {
System.out.println("ERROR : Could not open " + tracepath1);
// This trace should be valid
try {
final LTTngTextTrace tmpStream = initializeEventStream();
- tmpEventType = (LttngEventType)tmpStream.getNextEvent( new TmfContext(null, 0) ).getType();
+ tmpEventType = (LttngEventType)tmpStream.readEvent( new TmfContext(null, 0) ).getType();
}
catch (final Exception e) {
fail("ERROR : Failed to get reference!");
// This trace should be valid
try {
final LTTngTextTrace tmpStream = initializeEventStream();
- tmpTime = (LttngTimestamp) tmpStream.getNextEvent(new TmfContext(null, 0)).getTimestamp();
+ tmpTime = (LttngTimestamp) tmpStream.readEvent(new TmfContext(null, 0)).getTimestamp();
} catch (final Exception e) {
fail("ERROR : Failed to get reference!");
}
// Seek to the beginning of the trace
tmpContext = tmptrace.seekEvent( tmpTime );
- tmpevent = (LttngEvent)tmptrace.getNextEvent(tmpContext);
+ tmpevent = (LttngEvent)tmptrace.readEvent(tmpContext);
while ( tmpevent != null ) {
- tmpevent = (LttngEvent)tmptrace.getNextEvent(tmpContext);
+ tmpevent = (LttngEvent)tmptrace.readEvent(tmpContext);
// Parse the events if it was asked
if ( (tmpevent != null) && (PARSE_EVENTS) )
final TmfContext tmpContext = new TmfContext(null, 0);
// We should be at the beginning of the trace, so we will just read the
// first event now
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpEvent is null after first getNextEvent()", null, tmpEvent);
assertEquals("tmpEvent has wrong timestamp after first getNextEvent()", firstEventTimestamp, tmpEvent.getTimestamp().getValue());
// Read the next event as well
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpEvent is null after second getNextEvent()", null, tmpEvent);
assertEquals("tmpEvent has wrong timestamp after second getNextEvent()", secondEventTimestamp, tmpEvent.getTimestamp().getValue());
}
// We should be at the beginning of the trace, we will seek at a certain
// timestamp
tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekTest1, (byte) -9, 0));
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext);
assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterSeekTest1, tmpEvent.getTimestamp().getValue());
assertNotSame("tmpEvent is null after first seekEvent()", null, tmpEvent);
// Seek to the last timestamp
tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekLast, (byte) -9, 0));
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after seekEvent() to last", null, tmpContext);
assertEquals("tmpContext has wrong timestamp after seekEvent() to last", contextValueAfterSeekLast, tmpEvent.getTimestamp().getValue());
assertNotSame("tmpEvent is null after seekEvent() to last ", null, tmpEvent);
// Seek to the first timestamp (startTime)
tmpContext = testStream1.seekEvent(new TmfTimestamp(firstEventTimestamp, (byte) -9, 0));
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpEvent is null after seekEvent() to start ", null, tmpEvent);
assertTrue("tmpEvent has wrong reference after seekEvent() to start", firstEventReference.contains(tmpEvent.getReference()));
assertNotSame("tmpContext is null after seekEvent() to first", null, tmpContext);
// We should be at the beginning of the trace, we will seek at a certain
// timestamp
tmpContext = testStream1.seekEvent(indexToSeekTest1);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext);
assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterSeekTest1, tmpEvent.getTimestamp().getValue());
assertNotSame("tmpEvent is null after first seekEvent()", null, tmpEvent);
// Seek to the last timestamp
tmpContext = testStream1.seekEvent(indexToSeekLast);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext);
assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterSeekLast, tmpEvent.getTimestamp().getValue());
assertNotSame("tmpEvent is null after seekEvent() to last ", null, tmpEvent);
// Seek to the first timestamp (startTime)
tmpContext = testStream1.seekEvent(indexToSeekFirst);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after first seekEvent()", null, tmpContext);
assertEquals("tmpContext has wrong timestamp after first seekEvent()", contextValueAfterFirstEvent, tmpEvent.getTimestamp().getValue());
assertNotSame("tmpEvent is null after seekEvent() to start ", null, tmpEvent);
// We should be at the beginning of the trace, we will seek at a certain
// timestamp
- tmpContext = testStream1.seekLocation(new TmfLocation<Long>(locationToSeekTest1));
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(new TmfLocation<Long>(locationToSeekTest1));
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after first seekLocation()", null, tmpContext);
assertEquals("tmpContext has wrong timestamp after first seekLocation()", contextValueAfterSeekTest1, tmpEvent.getTimestamp().getValue());
assertNotSame("tmpEvent is null after first seekLocation()", null, tmpEvent);
assertTrue("tmpEvent has wrong reference after first seekLocation()", seek1EventReference.contains(tmpEvent.getReference()));
// Seek to the last timestamp
- tmpContext = testStream1.seekLocation(new TmfLocation<Long>(locationToSeekLast));
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(new TmfLocation<Long>(locationToSeekLast));
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after first seekLocation()", null, tmpContext);
assertEquals("tmpContext has wrong timestamp after first seekLocation()", contextValueAfterSeekLast, tmpEvent.getTimestamp().getValue());
assertNotSame("tmpEvent is null after seekLocation() to last ", null, tmpEvent);
assertTrue("tmpEvent has wrong reference after seekLocation() to last", seekLastEventReference.contains(tmpEvent.getReference()));
// Seek to the first timestamp (startTime)
- tmpContext = testStream1.seekLocation(new TmfLocation<Long>(locationToSeekFirst));
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(new TmfLocation<Long>(locationToSeekFirst));
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after first seekLocation()", null, tmpContext);
assertEquals("tmpContext has wrong timestamp after first seekLocation()", contextValueAfterFirstEvent, tmpEvent.getTimestamp().getValue());
assertNotSame("tmpEvent is null after seekLocation() to start ", null, tmpEvent);
final TmfContext tmpContext = new TmfContext(null, 0);
// We should be at the beginning of the trace, so we will just read the first event now
- tmpEvent = testStream1.getNextEvent(tmpContext );
+ tmpEvent = testStream1.readEvent(tmpContext );
assertNotSame("tmpEvent is null after first getNextEvent()",null,tmpEvent );
assertEquals("tmpEvent has wrong timestamp after first getNextEvent()",firstEventTimestamp,tmpEvent.getTimestamp().getValue() );
// Read the next event as well
- tmpEvent = testStream1.getNextEvent( tmpContext);
+ tmpEvent = testStream1.readEvent( tmpContext);
assertNotSame("tmpEvent is null after second getNextEvent()",null,tmpEvent );
assertEquals("tmpEvent has wrong timestamp after second getNextEvent()",secondEventTimestamp,tmpEvent.getTimestamp().getValue() );
}
// We should be at the beginning of the trace, we will seek at a certain timestamp
tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekTest1, (byte) -9, 0));
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext );
assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterSeekTest1,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
assertNotSame("tmpEvent is null after first seekEvent()",null,tmpEvent );
// Seek to the last timestamp
tmpContext = testStream1.seekEvent(new TmfTimestamp(timestampToSeekLast, (byte) -9, 0));
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after seekEvent() to last",null,tmpContext );
assertEquals("tmpContext has wrong timestamp after seekEvent() to last",contextValueAfterSeekLast,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
assertNotSame("tmpEvent is null after seekEvent() to last ",null,tmpEvent );
// Seek to the first timestamp (startTime)
tmpContext = testStream1.seekEvent(new TmfTimestamp(firstEventTimestamp, (byte) -9, 0));
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpEvent is null after seekEvent() to start ",null,tmpEvent );
assertTrue("tmpEvent has wrong reference after seekEvent() to start", firstEventReference.contains(tmpEvent.getReference()));
assertNotSame("tmpContext is null after seekEvent() to first",null,tmpContext );
// We should be at the beginning of the trace, we will seek at a certain timestamp
tmpContext = testStream1.seekEvent(indexToSeekTest1);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext );
assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterSeekTest1,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
assertNotSame("tmpEvent is null after first seekEvent()",null,tmpEvent );
// Seek to the last timestamp
tmpContext = testStream1.seekEvent(indexToSeekLast);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext );
assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterSeekLast,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
assertNotSame("tmpEvent is null after seekEvent() to last ",null,tmpEvent );
// Seek to the first timestamp (startTime)
tmpContext = testStream1.seekEvent(indexToSeekFirst);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext );
assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterFirstEvent,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
assertNotSame("tmpEvent is null after seekEvent() to start ",null,tmpEvent );
final LTTngTrace testStream1 = prepareStreamToTest();
// We should be at the beginning of the trace, we will seek at a certain timestamp
- tmpContext = testStream1.seekLocation(new LttngLocation(locationToSeekTest1));
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(new LttngLocation(locationToSeekTest1));
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after first seekLocation()",null,tmpContext );
assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterSeekTest1,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
assertNotSame("tmpEvent is null after first seekLocation()",null,tmpEvent );
assertTrue("tmpEvent has wrong reference after first seekLocation()", seek1EventReference.contains(tmpEvent.getReference()));
// Seek to the last timestamp
- tmpContext = testStream1.seekLocation(new LttngLocation(locationToSeekLast));
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(new LttngLocation(locationToSeekLast));
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after first seekLocation()",null,tmpContext );
assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterSeekLast,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
assertNotSame("tmpEvent is null after seekLocation() to last ",null,tmpEvent );
assertTrue("tmpEvent has wrong reference after seekLocation() to last", seekLastEventReference.contains(tmpEvent.getReference()));
// Seek to the first timestamp (startTime)
- tmpContext = testStream1.seekLocation(new LttngLocation(locationToSeekFirst));
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(new LttngLocation(locationToSeekFirst));
+ tmpEvent = testStream1.readEvent(tmpContext);
assertNotSame("tmpContext is null after first seekLocation()",null,tmpContext );
assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterFirstEvent,((TmfTimestamp)tmpEvent.getTimestamp()).getValue() );
assertNotSame("tmpEvent is null after seekLocation() to start ",null,tmpEvent );
final LTTngTrace testStream1 = prepareStreamToTest();
// Test LttngLocation after a seek
- tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
+ tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
LttngLocation location = (LttngLocation) tmpContext.getLocation().clone();
assertTrue("location has wrong flag", location.isLastOperationSeek());
assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue());
- tmpContext = testStream1.seekLocation(location);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(location);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
// Test LttngLocation after a parse
- tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
+ tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
tmpEvent = testStream.parseEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
location = (LttngLocation) tmpContext.getLocation().clone();
assertTrue("location has wrong flag", location.isLastOperationParse());
assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue());
- tmpContext = testStream1.seekLocation(location);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(location);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
// Test LttngLocation after a getNext
- tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
- tmpEvent = testStream.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
+ tmpEvent = testStream.readEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
location = (LttngLocation) tmpContext.getLocation().clone();
assertTrue("location has wrong flag", location.isLastOperationReadNext());
assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue());
- tmpContext = testStream1.seekLocation(location);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(location);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
// Test LttngLocation after a parse and parse
- tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
+ tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
tmpEvent = testStream.parseEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
tmpEvent = testStream.parseEvent(tmpContext);
location = (LttngLocation) tmpContext.getLocation().clone();
assertTrue("location has wrong flag", location.isLastOperationParse());
assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue());
- tmpContext = testStream1.seekLocation(location);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(location);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
// Test LttngLocation after a getNext and getNext
- tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
- tmpEvent = testStream.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
+ tmpEvent = testStream.readEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
- tmpEvent = testStream.getNextEvent(tmpContext);
+ tmpEvent = testStream.readEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
location = (LttngLocation) tmpContext.getLocation().clone();
assertTrue("location has wrong flag", location.isLastOperationReadNext());
assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
- tmpContext = testStream1.seekLocation(location);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(location);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue());
// Test LttngLocation after a getNext and parse
- tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
- tmpEvent = testStream.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
+ tmpEvent = testStream.readEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
tmpEvent = testStream.parseEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
location = (LttngLocation) tmpContext.getLocation().clone();
assertTrue("location has wrong flag", location.isLastOperationParse());
assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
- tmpContext = testStream1.seekLocation(location);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(location);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
// Test LttngLocation after a parse and getNext
- tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
+ tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
tmpEvent = testStream.parseEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
- tmpEvent = testStream.getNextEvent(tmpContext);
+ tmpEvent = testStream.readEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
location = (LttngLocation) tmpContext.getLocation().clone();
assertTrue("location has wrong flag", location.isLastOperationReadNext());
assertEquals("location has wrong operation time", seekTimestamp, location.getOperationTimeValue());
- tmpContext = testStream1.seekLocation(location);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(location);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
// Test LttngLocation after a parse, getNext and parse
- tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
+ tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
tmpEvent = testStream.parseEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
- tmpEvent = testStream.getNextEvent(tmpContext);
+ tmpEvent = testStream.readEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
tmpEvent = testStream.parseEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
location = (LttngLocation) tmpContext.getLocation().clone();
assertTrue("location has wrong flag", location.isLastOperationParse());
assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
- tmpContext = testStream1.seekLocation(location);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(location);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
// Test LttngLocation after a parse, getNext and getNext
- tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
+ tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
tmpEvent = testStream.parseEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
- tmpEvent = testStream.getNextEvent(tmpContext);
+ tmpEvent = testStream.readEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
- tmpEvent = testStream.getNextEvent(tmpContext);
+ tmpEvent = testStream.readEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
location = (LttngLocation) tmpContext.getLocation().clone();
assertTrue("location has wrong flag", location.isLastOperationReadNext());
assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
- tmpContext = testStream1.seekLocation(location);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(location);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue());
// Test LttngLocation after a getNext, parse and parse
- tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
- tmpEvent = testStream.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
+ tmpEvent = testStream.readEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
tmpEvent = testStream.parseEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
location = (LttngLocation) tmpContext.getLocation().clone();
assertTrue("location has wrong flag", location.isLastOperationParse());
assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
- tmpContext = testStream1.seekLocation(location);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(location);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
// Test LttngLocation after a getNext, parse and getNext
- tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
- tmpEvent = testStream.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
+ tmpEvent = testStream.readEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
tmpEvent = testStream.parseEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
- tmpEvent = testStream.getNextEvent(tmpContext);
+ tmpEvent = testStream.readEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
location = (LttngLocation) tmpContext.getLocation().clone();
assertTrue("location has wrong flag", location.isLastOperationReadNext());
assertEquals("location has wrong operation time", nextEventTimestamp, location.getOperationTimeValue());
- tmpContext = testStream1.seekLocation(location);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(location);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue());
// Test LttngLocation after a getNext, getNext and parse
- tmpContext = testStream1.seekLocation(new LttngLocation(seekTimestamp));
- tmpEvent = testStream.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(new LttngLocation(seekTimestamp));
+ tmpEvent = testStream.readEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", seekTimestamp, tmpEvent.getTimestamp().getValue());
- tmpEvent = testStream.getNextEvent(tmpContext);
+ tmpEvent = testStream.readEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp, tmpEvent.getTimestamp().getValue());
tmpEvent = testStream.parseEvent(tmpContext);
assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue());
location = (LttngLocation) tmpContext.getLocation().clone();
assertTrue("location has wrong flag", location.isLastOperationParse());
assertEquals("location has wrong operation time", nextnextEventTimestamp, location.getOperationTimeValue());
- tmpContext = testStream1.seekLocation(location);
- tmpEvent = testStream1.getNextEvent(tmpContext);
+ tmpContext = testStream1.seekEvent(location);
+ tmpEvent = testStream1.readEvent(tmpContext);
assertTrue("tmpContext is null after getNextEvent()", tmpEvent != null);
assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp, tmpEvent.getTimestamp().getValue());
}
import org.eclipse.linuxtools.lttng.jni.JniEvent;
import org.eclipse.linuxtools.tmf.core.event.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.TmfContext;
import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
-public class LTTngTextTrace extends TmfTrace<LttngEvent> {
+public class LTTngTextTrace extends TmfTrace<LttngEvent> implements ITmfEventParser<LttngEvent> {
private LttngTimestamp eventTimestamp = null;
private String eventSource = null;
private LttngEventType eventType = null;
// fCheckpoints.add(new TmfCheckpoint(new LttngTimestamp(0L), new TmfLocation<Long>(0L)));
ITmfContext context = new TmfContext(new TmfLocation<Long>(0L), 0);
fIndexer.updateIndex(context, new LttngTimestamp(0L));
+ fParser = (ITmfEventParser) this;
// }
// else {
// indexTrace(true);
final Long endTime = currentLttngEvent.getTimestamp().getValue();
positionToFirstEvent();
- getNextEvent(new TmfContext(null, 0));
+ readEvent(new TmfContext(null, 0));
final Long starTime = currentLttngEvent.getTimestamp().getValue();
positionToFirstEvent();
@Override
@SuppressWarnings("unchecked")
- public TmfContext seekLocation(ITmfLocation<?> location) {
+ public TmfContext seekEvent(ITmfLocation<?> location) {
if (location == null)
location = new TmfLocation<Long>(0L);
}
@Override
- public TmfContext seekLocation(final double ratio) {
+ public TmfContext seekEvent(final double ratio) {
// TODO Auto-generated method stub
return null;
}
@Override
public LttngEvent parseEvent(ITmfContext context) {
- context = seekLocation(context.getLocation());
+ context = seekEvent(context.getLocation());
return parseMyNextEvent(context);
}
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
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.TmfTrace;
* LTTng trace implementation. It accesses the C trace handling library
* (seeking, reading and parsing) through the JNI component.
*/
-public class LTTngTrace extends TmfTrace<LttngEvent> {
+public class LTTngTrace extends TmfTrace<LttngEvent> implements ITmfEventParser<LttngEvent> {
public final static boolean PRINT_DEBUG = false;
public final static boolean UNIQUE_EVENT = true;
// Set the currentEvent to the eventContent
eventContent.setEvent(currentLttngEvent);
+ fParser = (ITmfEventParser) this;
+
// // Bypass indexing if asked
// if ( bypassIndexing == false ) {
// indexTrace(true);
if (jniTrace == null
|| (!jniTrace.isLiveTraceSupported() || !LiveTraceManager.isLiveTrace(jniTrace.getTracepath()))) {
// Set the time range of the trace
- final TmfContext context = seekLocation(null);
- final LttngEvent event = getNextEvent(context);
+ final TmfContext context = seekEvent(0);
+ final LttngEvent event = readEvent(context);
final LttngTimestamp startTime = new LttngTimestamp(event.getTimestamp());
final LttngTimestamp endTime = new LttngTimestamp(currentJniTrace.getEndTime().getTime());
setTimeRange(new TmfTimeRange(startTime, endTime));
}
// Set the time range of the trace
- final TmfContext context = seekLocation(null);
- final LttngEvent event = getNextEvent(context);
+ final TmfContext context = seekEvent(0);
+ final LttngEvent event = readEvent(context);
setEndTime(TmfTimestamp.BIG_BANG);
final long startTime = event != null ? event.getTimestamp().getValue() : TmfTimestamp.BIG_BANG.getValue();
fStreamingInterval = LTTNG_STREAMING_INTERVAL;
* @see org.eclipse.linuxtools.tmf.core.trace.TmfContext
*/
@Override
- public synchronized TmfContext seekLocation(final ITmfLocation<?> location) {
+ public synchronized TmfContext seekEvent(final ITmfLocation<?> location) {
// // [lmcfrch]
// lastTime = 0;
// If the location is marked with the read next flag
// then it is pointing to the next event following the operation time
if (curLocation.isLastOperationReadNext())
- getNextEvent(context);
+ readEvent(context);
return context;
}
}
@Override
- public TmfContext seekLocation(final double ratio) {
+ public TmfContext seekEvent(final double ratio) {
// TODO Auto-generated method stub
return null;
}
public int nbEventsRead = 0;
@Override
- public synchronized LttngEvent getNextEvent(final ITmfContext context) {
+ public synchronized LttngEvent readEvent(final ITmfContext context) {
if (PRINT_DEBUG)
System.out.println("getNextEvent(context) context.getLocation() -> " //$NON-NLS-1$
import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
/**
* <b><u>TmfEventParserStub</u></b>
* @see org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser#parseNextEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfTrace, org.eclipse.linuxtools.tmf.core.trace.TmfContext)
*/
@Override
- public ITmfEvent parseNextEvent(ITmfTrace<LttngEvent> stream, ITmfContext context)
- throws IOException {
+ public ITmfEvent parseEvent(ITmfContext context) {
// TODO Auto-generated method stub
return null;
}
import org.eclipse.core.resources.IResource;
import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
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.TmfLocation;
* Dummy test trace. Use in conjunction with LTTngEventParserStub.
*/
@SuppressWarnings("nls")
-public class LTTngTraceStub extends TmfTrace<LttngEvent> {
+public class LTTngTraceStub extends TmfTrace<LttngEvent> implements ITmfEventParser<LttngEvent> {
// ========================================================================
// Attributes
*/
@Override
@SuppressWarnings("unchecked")
- public TmfContext seekLocation(final ITmfLocation<?> location) {
+ public TmfContext seekEvent(final ITmfLocation<?> location) {
TmfContext context = null;
try {
synchronized(fTrace) {
}
@Override
- public TmfContext seekLocation(final double ratio) {
+ public TmfContext seekEvent(final double ratio) {
// TODO Auto-generated method stub
return null;
}
*/
@Override
public ITmfEvent parseEvent(final ITmfContext context) {
- try {
+// try {
// paserNextEvent updates the context
- final LttngEvent event = (LttngEvent) fParser.parseNextEvent(this, context);
+ final LttngEvent event = (LttngEvent) fParser.parseEvent(context);
// if (event != null) {
// context.setTimestamp(event.getTimestamp());
// }
return event;
- }
- catch (final IOException e) {
- e.printStackTrace();
- }
- return null;
+// }
+// catch (final IOException e) {
+// e.printStackTrace();
+// }
+// return null;
}
/* (non-Javadoc)
// Validate that each checkpoint points to the right event
for (int i = 0; i < checkpoints.size(); i++) {
final TmfCheckpoint checkpoint = checkpoints.get(i);
- final TmfExperimentContext context = fExperiment.seekLocation(checkpoint.getLocation());
+ final TmfExperimentContext context = fExperiment.seekEvent(checkpoint.getLocation());
final ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event rank", i * pageSize, context.getRank());
assertTrue("Timestamp", (checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
public void testSeekLocationOnCacheBoundary() throws Exception {
// Position trace at event rank 0
- TmfContext context = fExperiment.seekLocation(null);
+ TmfContext context = fExperiment.seekEvent(0);
assertEquals("Event rank", 0, context.getRank());
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 2, context.getRank());
// Position trace at event rank 1000
TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation());
+ context = fExperiment.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", 1000, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
// Position trace at event rank 4000
tmpContext = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation());
+ context = fExperiment.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", 4000, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4001, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4002, event.getTimestamp().getValue());
assertEquals("Event rank", 4002, context.getRank());
}
// Position trace at event rank 9
TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
- TmfContext context = fExperiment.seekLocation(tmpContext.getLocation());
+ TmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", 9, context.getRank());
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
// Position trace at event rank 999
tmpContext = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation());
+ context = fExperiment.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", 999, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
// Position trace at event rank 1001
tmpContext = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation());
+ context = fExperiment.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", 1001, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
// Position trace at event rank 4500
tmpContext = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation());
+ context = fExperiment.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", 4500, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
public void testSeekLocationOutOfScope() throws Exception {
// Position trace at beginning
- TmfContext tmpContext = fExperiment.seekLocation(null);
- final TmfContext context = fExperiment.seekLocation(tmpContext.getLocation());
+ TmfContext tmpContext = fExperiment.seekEvent(0);
+ final TmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", 0, context.getRank());
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4001, context.getRank());
}
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 2, context.getRank());
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4001, context.getRank());
}
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
// Read NB_EVENTS
ITmfEvent event = null;;
for (int i = 0; i < NB_READS; i++) {
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue());
assertEquals("Event rank", i + 1, context.getRank());
}
// On lower bound, returns the first event (ts = 0)
final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
- ITmfEvent event = fExperiment.getNextEvent(context);
+ ITmfEvent event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
for (int i = 2; i < 20; i++) {
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", i, event.getTimestamp().getValue());
}
}
// Validate that each checkpoint points to the right event
for (int i = 0; i < checkpoints.size(); i++) {
final TmfCheckpoint checkpoint = checkpoints.get(i);
- final TmfExperimentContext context = fExperiment.seekLocation(checkpoint.getLocation());
+ final TmfExperimentContext context = fExperiment.seekEvent(checkpoint.getLocation());
final ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event rank", context.getRank(), i * pageSize);
assertTrue("Timestamp", (checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
public void testSeekLocationOnCacheBoundary() throws Exception {
// Position trace at event rank 0
- TmfContext context = fExperiment.seekLocation(null);
+ TmfContext context = fExperiment.seekEvent(0);
assertEquals("Event rank", 0, context.getRank());
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 2, context.getRank());
// Position trace at event rank 1000
TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation());
+ context = fExperiment.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", 1000, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
// Position trace at event rank 4000
tmpContext = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation());
+ context = fExperiment.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", 4000, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4001, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4002, event.getTimestamp().getValue());
assertEquals("Event rank", 4002, context.getRank());
}
// Position trace at event rank 9
TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
- TmfContext context = fExperiment.seekLocation(tmpContext.getLocation());
+ TmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", 9, context.getRank());
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
// Position trace at event rank 999
tmpContext = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation());
+ context = fExperiment.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", 999, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
// Position trace at event rank 1001
tmpContext = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation());
+ context = fExperiment.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", 1001, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
// Position trace at event rank 4500
tmpContext = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation());
+ context = fExperiment.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", 4500, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
public void testSeekLocationOutOfScope() throws Exception {
// Position trace at beginning
- TmfContext tmpContext = fExperiment.seekLocation(null);
- final TmfContext context = fExperiment.seekLocation(tmpContext.getLocation());
+ TmfContext tmpContext = fExperiment.seekEvent(0);
+ final TmfContext context = fExperiment.seekEvent(tmpContext.getLocation());
assertEquals("Event rank", 0, context.getRank());
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4001, context.getRank());
}
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 2, context.getRank());
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4001, context.getRank());
}
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
// Read NB_EVENTS
ITmfEvent event = null;;
for (int i = 0; i < NB_READS; i++) {
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue());
assertEquals("Event rank", i + 1, context.getRank());
}
// On lower bound, returns the first event (ts = 0)
final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
- ITmfEvent event = fExperiment.getNextEvent(context);
+ ITmfEvent event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
for (int i = 2; i < 20; i++) {
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", i, event.getTimestamp().getValue());
}
}
+/*******************************************************************************
+ * 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 - Adjusted for new Trace Model
+ *******************************************************************************/
+
package org.eclipse.linuxtools.tmf.core.tests.trace;
import junit.framework.Test;
import org.eclipse.linuxtools.internal.tmf.core.TmfCorePlugin;
+/**
+ * <b><u>AllTests</u></b>
+ * <p>
+ */
@SuppressWarnings("nls")
public class AllTests {
TestSuite suite = new TestSuite("Test suite for " + TmfCorePlugin.PLUGIN_ID + ".trace"); //$NON-NLS-1$);
//$JUnit-BEGIN$
suite.addTestSuite(TmfLocationTest.class);
+ suite.addTestSuite(TmfContextTest.class);
suite.addTestSuite(TmfCheckpointTest.class);
- suite.addTestSuite(TmfContextTest.class);
+ suite.addTestSuite(TmfCheckpointIndexTest.class);
suite.addTestSuite(TmfTraceTest.class);
//$JUnit-END$
return suite;
// Validate that each checkpoint points to the right event
for (int i = 0; i < checkpoints.size(); i++) {
final TmfCheckpoint checkpoint = checkpoints.get(i);
- final TmfExperimentContext context = fExperiment.seekLocation(checkpoint.getLocation());
+ final TmfExperimentContext context = fExperiment.seekEvent(checkpoint.getLocation());
final ITmfEvent event = fExperiment.parseEvent(context);
// assertEquals("Event rank", context.getRank(), i * pageSize);
assertTrue("Timestamp", (checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
for (int i = 1; i < 20; i++) {
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", i, event.getTimestamp().getValue());
}
// On lower bound, returns the first event (ts = 0)
final TmfContext context = fExperiment.seekEvent(new TmfTimestamp(0, SCALE, 0));
- ITmfEvent event = fExperiment.getNextEvent(context);
+ ITmfEvent event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
for (int i = 2; i < 20; i++) {
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", i, event.getTimestamp().getValue());
}
}
public void testSeekLocationOnCacheBoundary() throws Exception {
// Position trace at event rank 0
- TmfContext context = fExperiment.seekLocation(null);
+ TmfContext context = fExperiment.seekEvent(0);
// assertEquals("Event rank", 0, context.getRank());
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
// assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
// assertEquals("Event rank", 1, context.getRank());
// Position trace at event rank 1000
TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(1001, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+ context = fExperiment.seekEvent(tmpContext.getLocation().clone());
// assertEquals("Event rank", 1000, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
// assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
// assertEquals("Event rank", 1001, context.getRank());
// Position trace at event rank 4000
tmpContext = fExperiment.seekEvent(new TmfTimestamp(4001, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+ context = fExperiment.seekEvent(tmpContext.getLocation().clone());
// assertEquals("Event rank", 4000, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
// assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
// assertEquals("Event rank", 4001, context.getRank());
}
// Position trace at event rank 9
TmfContext tmpContext = fExperiment.seekEvent(new TmfTimestamp(10, SCALE, 0));
- TmfContext context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+ TmfContext context = fExperiment.seekEvent(tmpContext.getLocation().clone());
// assertEquals("Event rank", 9, context.getRank());
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
// assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
// assertEquals("Event rank", 10, context.getRank());
// Position trace at event rank 999
tmpContext = fExperiment.seekEvent(new TmfTimestamp(1000, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+ context = fExperiment.seekEvent(tmpContext.getLocation().clone());
// assertEquals("Event rank", 999, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
// assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
// assertEquals("Event rank", 1000, context.getRank());
// Position trace at event rank 1001
tmpContext = fExperiment.seekEvent(new TmfTimestamp(1002, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+ context = fExperiment.seekEvent(tmpContext.getLocation().clone());
// assertEquals("Event rank", 1001, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
// assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
// assertEquals("Event rank", 1002, context.getRank());
// Position trace at event rank 4500
tmpContext = fExperiment.seekEvent(new TmfTimestamp(4501, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+ context = fExperiment.seekEvent(tmpContext.getLocation().clone());
// assertEquals("Event rank", 4500, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
// assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
// assertEquals("Event rank", 4501, context.getRank());
}
public void testSeekLocationOutOfScope() throws Exception {
// Position trace at beginning
- TmfContext tmpContext = fExperiment.seekLocation(null);
- TmfContext context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+ TmfContext tmpContext = fExperiment.seekEvent(0);
+ TmfContext context = fExperiment.seekEvent(tmpContext.getLocation().clone());
// assertEquals("Event rank", 0, context.getRank());
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
// assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
// assertEquals("Event rank", 1, context.getRank());
// Position trace at event passed the end
tmpContext = fExperiment.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
- context = fExperiment.seekLocation(tmpContext.getLocation().clone());
+ context = fExperiment.seekEvent(tmpContext.getLocation().clone());
// assertEquals("Event rank", NB_EVENTS, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", null, event);
// assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", null, event);
// assertEquals("Event rank", NB_EVENTS, context.getRank());
}
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4001, context.getRank());
}
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 2, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", null, event);
assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", null, event);
assertEquals("Event rank", NB_EVENTS, context.getRank());
}
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4000, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4001, context.getRank());
}
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
ITmfEvent event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
event = fExperiment.parseEvent(context);
assertEquals("Event timestamp", null, event);
assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fExperiment.getNextEvent(context);
+ event = fExperiment.readEvent(context);
assertEquals("Event timestamp", null, event);
assertEquals("Event rank", NB_EVENTS, context.getRank());
}
import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
import org.eclipse.linuxtools.tmf.core.component.TmfProviderManager;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfTraceIndexer;
import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
/**
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
testfile = new File(FileLocator.toFileURL(location).toURI());
- original = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, new TmfTraceIndexer(null));
+ original = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, new TmfCheckpointIndexer(null));
trace = new TmfTraceStub(original);
trace.indexTrace();
} catch (final URISyntaxException e) {
}
// ------------------------------------------------------------------------
- // seekEvent on timestamp
+ // seekEvent on location (note: does not reliably set the rank)
+ // ------------------------------------------------------------------------
+
+ public void testSeekEventOnCacheBoundary() throws Exception {
+
+ // Position trace at event rank 0
+ ITmfContext context = fTrace.seekEvent(0);
+ ITmfEvent event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", 0, context.getRank());
+
+ context = fTrace.seekEvent(context.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.readEvent(context);
+ assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ // Position trace at event rank 1000
+ ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0));
+ context = fTrace.seekEvent(tmpContext.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.readEvent(context);
+ assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ // Position trace at event rank 4000
+ tmpContext = fTrace.seekEvent(new TmfTimestamp(4001, SCALE, 0));
+ context = fTrace.seekEvent(tmpContext.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.readEvent(context);
+ assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+ }
+
+ public void testSeekEventNotOnCacheBoundary() throws Exception {
+
+ // Position trace at event rank 9
+ ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0));
+ TmfContext context = fTrace.seekEvent(tmpContext.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ ITmfEvent event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.readEvent(context);
+ assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ // Position trace at event rank 999
+ tmpContext = fTrace.seekEvent(new TmfTimestamp(1000, SCALE, 0));
+ context = fTrace.seekEvent(tmpContext.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.readEvent(context);
+ assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ // Position trace at event rank 1001
+ tmpContext = fTrace.seekEvent(new TmfTimestamp(1002, SCALE, 0));
+ context = fTrace.seekEvent(tmpContext.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.readEvent(context);
+ assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ // Position trace at event rank 4500
+ tmpContext = fTrace.seekEvent(new TmfTimestamp(4501, SCALE, 0));
+ context = fTrace.seekEvent(tmpContext.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.readEvent(context);
+ assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+ }
+
+ public void testSeekEventOutOfScope() throws Exception {
+
+ // Position trace at beginning
+ ITmfContext tmpContext = fTrace.seekEvent(0);
+ ITmfContext context = fTrace.seekEvent(tmpContext.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ ITmfEvent event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.readEvent(context);
+ assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ // Position trace at event passed the end
+ tmpContext = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
+ context = fTrace.seekEvent(tmpContext.getLocation());
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.parseEvent(context);
+ assertEquals("Event timestamp", null, event);
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+
+ event = fTrace.readEvent(context);
+ assertEquals("Event timestamp", null, event);
+ assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
+ }
+
+ // ------------------------------------------------------------------------
+ // seekEvent on timestamp (note: does not reliably set the rank)
// ------------------------------------------------------------------------
public void testSeekEventOnNullTimestamp() throws Exception {
// Position trace at event rank 0
- ITmfContext context = fTrace.seekEvent(null);
+ ITmfContext context = fTrace.seekEvent((ITmfTimestamp) null);
assertEquals("Event rank", 0, context.getRank());
ITmfEvent event = fTrace.parseEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4000, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4001, context.getRank());
}
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 2, event.getTimestamp().getValue());
assertEquals("Event rank", 2, context.getRank());
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
assertEquals("Event timestamp", null, event);
assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", null, event);
assertEquals("Event rank", NB_EVENTS, context.getRank());
}
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4000, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
assertEquals("Event rank", 4001, context.getRank());
}
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 9, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
assertEquals("Event rank", 10, context.getRank());
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 999, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
assertEquals("Event rank", 1000, context.getRank());
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1001, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
assertEquals("Event rank", 1002, context.getRank());
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4500, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
assertEquals("Event rank", 4501, context.getRank());
}
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 0, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
assertEquals("Event rank", 1, context.getRank());
assertEquals("Event timestamp", null, event);
assertEquals("Event rank", NB_EVENTS, context.getRank());
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", null, event);
assertEquals("Event rank", NB_EVENTS, context.getRank());
}
// Position the trace at event NB_READS
for (int i = 1; i < NB_READS; i++) {
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", i, event.getTimestamp().getValue());
}
}
// ------------------------------------------------------------------------
- // getNextEvent - updates the context
+ // readEvent - updates the context
// ------------------------------------------------------------------------
- public void testGetNextEvent() throws Exception {
+ public void testGetEvent() throws Exception {
final int NB_READS = 20;
// Read NB_EVENTS
ITmfEvent event;
for (int i = 0; i < NB_READS; i++) {
- event = fTrace.getNextEvent(context);
+ event = fTrace.readEvent(context);
assertEquals("Event timestamp", i + 1, event.getTimestamp().getValue());
assertEquals("Event rank", i + 1, context.getRank());
}
// ------------------------------------------------------------------------
@SuppressWarnings("unchecked")
- public void testProcessRequestForNbEvents() throws Exception {
+ public void testProcessEventRequestForAllEvents() throws Exception {
+ final int BLOCK_SIZE = 1;
+ final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+
+ final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
+ final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
+ @Override
+ public void handleData(final TmfEvent event) {
+ super.handleData(event);
+ requestedEvents.add(event);
+ }
+ };
+ final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
+ providers[0].sendRequest(request);
+ request.waitForCompletion();
+
+ assertEquals("nbEvents", NB_EVENTS, requestedEvents.size());
+ assertTrue("isCompleted", request.isCompleted());
+ assertFalse("isCancelled", request.isCancelled());
+
+ // Ensure that we have distinct events.
+ // Don't go overboard: we are not validating the stub!
+ for (int i = 0; i < NB_EVENTS; i++) {
+ assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testProcessEventRequestForNbEvents() throws Exception {
final int BLOCK_SIZE = 100;
final int NB_EVENTS = 1000;
final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
// Ensure that we have distinct events.
// Don't go overboard: we are not validating the stub!
for (int i = 0; i < NB_EVENTS; i++) {
- assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
+ assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
}
}
@SuppressWarnings("unchecked")
- public void testProcessRequestForAllEvents() throws Exception {
+ public void testProcessEventRequestForSomeEvents() throws Exception {
final int BLOCK_SIZE = 1;
+ final long startTime = 100;
+ final int NB_EVENTS = 1000;
final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
- final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
+ final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
@Override
public void handleData(final TmfEvent event) {
// Ensure that we have distinct events.
// Don't go overboard: we are not validating the stub!
for (int i = 0; i < NB_EVENTS; i++) {
- assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
+ assertEquals("Distinct events", startTime + i, requestedEvents.get(i).getTimestamp().getValue());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testProcessEventRequestForOtherEvents() throws Exception {
+ final int BLOCK_SIZE = 1;
+ final int startIndex = 99;
+ final long startTime = 100;
+ final int NB_EVENTS = 1000;
+ final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+
+ final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
+ final TmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, range, startIndex, NB_EVENTS, BLOCK_SIZE) {
+ @Override
+ public void handleData(final TmfEvent event) {
+ super.handleData(event);
+ requestedEvents.add(event);
+ }
+ };
+ final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
+ providers[0].sendRequest(request);
+ request.waitForCompletion();
+
+ assertEquals("nbEvents", NB_EVENTS, requestedEvents.size());
+ assertTrue("isCompleted", request.isCompleted());
+ assertFalse("isCancelled", request.isCancelled());
+
+ // Ensure that we have distinct events.
+ // Don't go overboard: we are not validating the stub!
+ for (int i = 0; i < NB_EVENTS; i++) {
+ assertEquals("Distinct events", startTime + i, requestedEvents.get(i).getTimestamp().getValue());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testProcessDataRequestForSomeEvents() throws Exception {
+ final int startIndex = 100;
+ final int NB_EVENTS = 1000;
+ final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+
+ final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(TmfEvent.class, startIndex, NB_EVENTS) {
+ @Override
+ public void handleData(final TmfEvent event) {
+ super.handleData(event);
+ requestedEvents.add(event);
+ }
+ };
+ final ITmfDataProvider<TmfEvent>[] providers = (ITmfDataProvider<TmfEvent>[]) TmfProviderManager.getProviders(TmfEvent.class, TmfTraceStub.class);
+ providers[0].sendRequest(request);
+ request.waitForCompletion();
+
+ assertEquals("nbEvents", NB_EVENTS, requestedEvents.size());
+ assertTrue("isCompleted", request.isCompleted());
+ assertFalse("isCancelled", request.isCancelled());
+
+ // Ensure that we have distinct events.
+ // Don't go overboard: we are not validating the stub!
+ for (int i = 0; i < NB_EVENTS; i++) {
+ assertEquals("Distinct events", startIndex + 1 + i, requestedEvents.get(i).getTimestamp().getValue());
}
}
assertEquals("toString", expected, fTrace.toString());
}
-
-// // ------------------------------------------------------------------------
-// // seekLocation
-// // Note: seekLocation() does not reliably set the rank
-// // ------------------------------------------------------------------------
-//
-// public void testSeekLocationOnCacheBoundary() throws Exception {
-//
-// // Position trace at event rank 0
-// TmfContext context = fTrace.seekLocation(null);
-// ITmfEvent event = fTrace.parseEvent(context);
-// assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-// assertEquals("Event rank", 0, context.getRank());
-//
-// context = fTrace.seekLocation(context.getLocation());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.parseEvent(context);
-// assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.getNextEvent(context);
-// assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// // Position trace at event rank 1000
-// ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(1001, SCALE, 0));
-// context = fTrace.seekLocation(tmpContext.getLocation());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.parseEvent(context);
-// assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.getNextEvent(context);
-// assertEquals("Event timestamp", 1001, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// // Position trace at event rank 4000
-// tmpContext = fTrace.seekEvent(new TmfTimestamp(4001, SCALE, 0));
-// context = fTrace.seekLocation(tmpContext.getLocation());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.parseEvent(context);
-// assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.getNextEvent(context);
-// assertEquals("Event timestamp", 4001, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-// }
-//
-// public void testSeekLocationNotOnCacheBoundary() throws Exception {
-//
-// // Position trace at event rank 9
-// ITmfContext tmpContext = fTrace.seekEvent(new TmfTimestamp(10, SCALE, 0));
-// TmfContext context = fTrace.seekLocation(tmpContext.getLocation());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// ITmfEvent event = fTrace.parseEvent(context);
-// assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.getNextEvent(context);
-// assertEquals("Event timestamp", 10, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// // Position trace at event rank 999
-// tmpContext = fTrace.seekEvent(new TmfTimestamp(1000, SCALE, 0));
-// context = fTrace.seekLocation(tmpContext.getLocation());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.parseEvent(context);
-// assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.getNextEvent(context);
-// assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// // Position trace at event rank 1001
-// tmpContext = fTrace.seekEvent(new TmfTimestamp(1002, SCALE, 0));
-// context = fTrace.seekLocation(tmpContext.getLocation());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.parseEvent(context);
-// assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.getNextEvent(context);
-// assertEquals("Event timestamp", 1002, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// // Position trace at event rank 4500
-// tmpContext = fTrace.seekEvent(new TmfTimestamp(4501, SCALE, 0));
-// context = fTrace.seekLocation(tmpContext.getLocation());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.parseEvent(context);
-// assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.getNextEvent(context);
-// assertEquals("Event timestamp", 4501, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-// }
-//
-// public void testSeekLocationOutOfScope() throws Exception {
-//
-// // Position trace at beginning
-// ITmfContext tmpContext = fTrace.seekLocation(null);
-// ITmfContext context = fTrace.seekLocation(tmpContext.getLocation());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// ITmfEvent event = fTrace.parseEvent(context);
-// assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.getNextEvent(context);
-// assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// // Position trace at event passed the end
-// tmpContext = fTrace.seekEvent(new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
-// context = fTrace.seekLocation(tmpContext.getLocation());
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.parseEvent(context);
-// assertEquals("Event timestamp", null, event);
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-//
-// event = fTrace.getNextEvent(context);
-// assertEquals("Event timestamp", null, event);
-// assertEquals("Event rank", ITmfContext.UNKNOWN_RANK, context.getRank());
-// }
-
- // ------------------------------------------------------------------------
- // Verify checkpoints
- // ------------------------------------------------------------------------
-
- // public void testTmfTraceIndexing() throws Exception {
- // assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getIndexPageSize());
- // 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());
- //
- // final Vector<TmfCheckpoint> checkpoints = fTrace.getCheckpoints();
- // final int pageSize = fTrace.getIndexPageSize();
- // assertTrue("Checkpoints exist", checkpoints != null);
- //
- // // Validate that each checkpoint points to the right event
- // for (int i = 0; i < checkpoints.size(); i++) {
- // final TmfCheckpoint checkpoint = checkpoints.get(i);
- // final TmfContext context = new TmfContext(checkpoint.getLocation(), i * pageSize);
- // final ITmfEvent event = fTrace.parseEvent(context);
- // assertTrue(context.getRank() == i * pageSize);
- // assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
- // }
- // }
-
}
\ No newline at end of file
import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
* TODO: Implement me. Please.
*/
@SuppressWarnings("nls")
-public class TmfEventParserStub implements ITmfEventParser<TmfEvent> {
+public class TmfEventParserStub implements ITmfEventParser<ITmfEvent> {
// ------------------------------------------------------------------------
// Attributes
private static final int NB_TYPES = 10;
private final TmfEventType[] fTypes;
+ private ITmfTrace<TmfEvent> fEventStream;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
- public TmfEventParserStub() {
+ public TmfEventParserStub(final ITmfTrace<TmfEvent> eventStream) {
+ fEventStream = eventStream;
fTypes = new TmfEventType[NB_TYPES];
for (int i = 0; i < NB_TYPES; i++) {
final Vector<String> fields = new Vector<String>();
static final String typePrefix = "Type-";
@Override
@SuppressWarnings("unchecked")
- public ITmfEvent parseNextEvent(final ITmfTrace<TmfEvent> eventStream, final ITmfContext context) throws IOException {
+ public ITmfEvent parseEvent(final ITmfContext context) {
- if (! (eventStream instanceof TmfTraceStub))
+ if (! (fEventStream instanceof TmfTraceStub))
return null;
// Highly inefficient...
- final RandomAccessFile stream = ((TmfTraceStub) eventStream).getStream();
+ final RandomAccessFile stream = ((TmfTraceStub) fEventStream).getStream();
// String name = eventStream.getName();
// name = name.substring(name.lastIndexOf('/') + 1);
long location = 0;
if (context != null)
location = ((TmfLocation<Long>) (context.getLocation())).getLocation();
- stream.seek(location);
try {
+ stream.seek(location);
+
final long ts = stream.readLong();
final String source = stream.readUTF();
final String type = stream.readUTF();
content.append("]");
final TmfEventField root = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, content.toString());
- final ITmfEvent event = new TmfEvent(eventStream,
+ final ITmfEvent event = new TmfEvent(fEventStream,
new TmfTimestamp(ts, -3, 0), // millisecs
source, fTypes[typeIndex], root, reference.toString());
return event;
} catch (final EOFException e) {
+ } catch (final IOException e) {
}
return null;
}
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
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;
* Dummy test trace. Use in conjunction with TmfEventParserStub.
*/
@SuppressWarnings("nls")
-public class TmfTraceStub extends TmfTrace<TmfEvent> {
+public class TmfTraceStub extends TmfTrace<TmfEvent> implements ITmfEventParser<TmfEvent> {
// ------------------------------------------------------------------------
// Attributes
// The actual stream
private RandomAccessFile fTrace;
- // The associated event parser
- private ITmfEventParser<TmfEvent> fParser;
+// // The associated event parser
+// private ITmfEventParser<TmfEvent> fParser;
// The synchronization lock
private final ReentrantLock fLock = new ReentrantLock();
*/
public TmfTraceStub() {
super();
- fParser = new TmfEventParserStub();
+ fParser = new TmfEventParserStub(this);
}
/**
public TmfTraceStub(final String path, final int cacheSize, final long interval) throws FileNotFoundException {
super(null, TmfEvent.class, path, cacheSize, interval);
fTrace = new RandomAccessFile(path, "r");
- fParser = new TmfEventParserStub();
+ fParser = new TmfEventParserStub(this);
}
/**
public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion) throws FileNotFoundException {
super(null, TmfEvent.class, path, cacheSize);
fTrace = new RandomAccessFile(path, "r");
- fParser = new TmfEventParserStub();
+ fParser = new TmfEventParserStub(this);
}
/**
public TmfTraceStub(final IResource resource, final String path, final int cacheSize, final boolean waitForCompletion) throws FileNotFoundException {
super(resource, TmfEvent.class, path, cacheSize);
fTrace = new RandomAccessFile(path, "r");
- fParser = new TmfEventParserStub();
+ fParser = new TmfEventParserStub(this);
}
/**
* @param parser
* @throws FileNotFoundException
*/
+ @SuppressWarnings("unchecked")
public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion,
final ITmfEventParser<TmfEvent> parser, final ITmfTraceIndexer<?> indexer) throws FileNotFoundException {
super(null, TmfEvent.class, path, cacheSize, 0, indexer);
fTrace = new RandomAccessFile(path, "r");
- fParser = (parser != null) ? parser : new TmfEventParserStub();
+ fParser = (ITmfEventParser<ITmfEvent>) ((parser != null) ? parser : new TmfEventParserStub(this));
}
/**
public TmfTraceStub(final TmfTraceStub trace) throws FileNotFoundException {
super(trace);
fTrace = new RandomAccessFile(getPath(), "r");
- fParser = new TmfEventParserStub();
+ fParser = new TmfEventParserStub(this);
}
public void indexTrace() {
@Override
public void initTrace(final IResource resource, final String path, final Class<TmfEvent> type) throws FileNotFoundException {
fTrace = new RandomAccessFile(path, "r");
- fParser = new TmfEventParserStub();
+ fParser = new TmfEventParserStub(this);
super.initTrace(resource, path, type);
}
@Override
@SuppressWarnings("unchecked")
- public TmfContext seekLocation(final ITmfLocation<?> location) {
+ public TmfContext seekEvent(final ITmfLocation<?> location) {
try {
fLock.lock();
try {
@Override
- public TmfContext seekLocation(final double ratio) {
+ public TmfContext seekEvent(final double ratio) {
fLock.lock();
try {
if (fTrace != null) {
final ITmfLocation<?> location = new TmfLocation<Long>(Long.valueOf((long) (ratio * fTrace.length())));
- final TmfContext context = seekLocation(location);
+ final TmfContext context = seekEvent(location);
context.setRank(ITmfContext.UNKNOWN_RANK);
return context;
}
try {
// parseNextEvent will update the context
if (fTrace != null) {
- final ITmfEvent event = fParser.parseNextEvent(this, context.clone());
+ final ITmfEvent event = fParser.parseEvent(context.clone());
return event;
}
- }
- catch (final IOException e) {
- e.printStackTrace();
+// }
+// catch (final IOException e) {
+// e.printStackTrace();
} finally {
fLock.unlock();
}
org.eclipse.linuxtools.tmf.core.filter.xml,
org.eclipse.linuxtools.tmf.core.interval,
org.eclipse.linuxtools.tmf.core.io,
- org.eclipse.linuxtools.tmf.core.parser,
org.eclipse.linuxtools.tmf.core.request,
org.eclipse.linuxtools.tmf.core.signal,
org.eclipse.linuxtools.tmf.core.statesystem,
// ------------------------------------------------------------------------
@Override
- public ITmfContext seekLocation(final ITmfLocation<?> location) {
+ public ITmfContext seekEvent(final ITmfLocation<?> location) {
CtfLocation currentLocation = (CtfLocation) location;
if (currentLocation == null)
currentLocation = new CtfLocation(0L);
* Seek rank ratio
*/
@Override
- public ITmfContext seekLocation(final double ratio) {
+ public ITmfContext seekEvent(final double ratio) {
iterator.seek((long) (this.fNbEvents * ratio));
return iterator;
}
@Override
- public CtfTmfEvent getNextEvent(final ITmfContext context) {
+ public CtfTmfEvent readEvent(final ITmfContext context) {
iterator.advance();
return iterator.getCurrentEvent();
}
- @Override
- public CtfTmfEvent parseEvent(final ITmfContext context) {
- return iterator.getCurrentEvent();
- }
+// @Override
+// public CtfTmfEvent parseEvent(final ITmfContext context) {
+// return iterator.getCurrentEvent();
+// }
@Override
public IResource getResource() {
*/
public ITmfTimestamp getTimestamp(final int index) {
final TmfExperimentContext context = seekEvent(index);
- final ITmfEvent event = getNextEvent(context);
+ final ITmfEvent event = readEvent(context);
return (event != null) ? event.getTimestamp() : null;
}
@SuppressWarnings("unchecked")
public T getNext(final ITmfContext context) {
if (context instanceof TmfExperimentContext)
- return (T) getNextEvent(context);
+ return (T) readEvent(context);
return null;
}
// Returns a brand new context based on the location provided
// and initializes the event queues
@Override
- public synchronized TmfExperimentContext seekLocation(final ITmfLocation<?> location) {
+ public synchronized TmfExperimentContext seekEvent(final ITmfLocation<?> location) {
// Validate the location
if (location != null && !(location instanceof TmfExperimentLocation))
return null; // Throw an exception?
final long traceRank = expLocation.getRanks()[i];
// Set the corresponding sub-context
- context.getContexts()[i] = fTraces[i].seekLocation(traceLocation);
+ context.getContexts()[i] = fTraces[i].seekEvent(traceLocation);
context.getContexts()[i].setRank(traceRank);
rank += traceRank;
* ourselves higher up.
*/
expLocation.getLocation().locations[i] = context.getContexts()[i].getLocation().clone();
- context.getEvents()[i] = fTraces[i].getNextEvent(context.getContexts()[i]);
+ context.getEvents()[i] = fTraces[i].readEvent(context.getContexts()[i]);
}
// Tracer.trace("Ctx: SeekLocation - done");
location = null;
}
- final TmfExperimentContext context = seekLocation(location);
+ final TmfExperimentContext context = seekEvent(location);
context.setRank((long) index * fIndexPageSize);
// And locate the event
ITmfEvent event = parseEvent(context);
while ((event != null) && (event.getTimestamp().compareTo(timestamp, false) < 0)) {
- getNextEvent(context);
+ readEvent(context);
event = parseEvent(context);
}
}
}
- final TmfExperimentContext context = seekLocation(location);
+ final TmfExperimentContext context = seekEvent(location);
context.setRank((long) index * fIndexPageSize);
// And locate the event
ITmfEvent event = parseEvent(context);
long pos = context.getRank();
while ((event != null) && (pos++ < rank)) {
- getNextEvent(context);
+ readEvent(context);
event = parseEvent(context);
}
}
@Override
- public TmfContext seekLocation(final double ratio) {
+ public TmfContext seekEvent(final double ratio) {
final TmfContext context = seekEvent((long) (ratio * getNbEvents()));
return context;
}
@Override
public double getLocationRatio(final ITmfLocation<?> location) {
if (location instanceof TmfExperimentLocation)
- return (double) seekLocation(location).getRank() / getNbEvents();
+ return (double) seekEvent(location).getRank() / getNbEvents();
return 0;
}
* @return the next event
*/
@Override
- public synchronized ITmfEvent getNextEvent(final ITmfContext context) {
+ public synchronized ITmfEvent readEvent(final ITmfContext context) {
// Validate the context
if (!(context instanceof TmfExperimentContext))
if (!context.equals(fExperimentContext))
// Tracer.trace("Ctx: Restoring context");
- fExperimentContext = seekLocation(context.getLocation());
+ fExperimentContext = seekEvent(context.getLocation());
final TmfExperimentContext expContext = (TmfExperimentContext) context;
final int lastTrace = expContext.getLastTrace();
if (lastTrace != TmfExperimentContext.NO_TRACE) {
final ITmfContext traceContext = expContext.getContexts()[lastTrace];
- expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].getNextEvent(traceContext);
+ expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].readEvent(traceContext);
expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
}
/* (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent(org.eclipse.linuxtools .tmf.trace.TmfContext)
*/
- @Override
+// @Override
public ITmfEvent parseEvent(final ITmfContext context) {
// Validate the context
if (!context.equals(fExperimentContext))
// Tracer.trace("Ctx: Restoring context");
- seekLocation(context.getLocation());
+ seekEvent(context.getLocation());
final TmfExperimentContext expContext = (TmfExperimentContext) context;
final int lastTrace = expContext.getLastTrace();
if (lastTrace != TmfExperimentContext.NO_TRACE) {
final ITmfContext traceContext = expContext.getContexts()[lastTrace];
- expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].getNextEvent(traceContext);
+ expContext.getEvents()[lastTrace] = expContext.getTraces()[lastTrace].readEvent(traceContext);
expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
fExperimentContext = (TmfExperimentContext) context;
}
fInitialized = true;
if (getStreamingInterval() == 0) {
- final TmfContext context = seekLocation(null);
+ final TmfContext context = seekEvent(0);
final ITmfEvent event = getNext(context);
if (event == null)
return;
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009 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.parser;
-
-import java.io.IOException;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-
-/**
- * <b><u>ITmfEventParser</u></b>
- * <p>
- */
-public interface ITmfEventParser<T extends ITmfEvent> {
-
- /**
- * @return a parsed event
- * @throws IOException
- */
- /**
- * Parses the trace event referenced by the context.
- *
- * @param trace the event stream
- * @param context the trace context
- * @return the parsed event
- * @throws IOException
- */
- public ITmfEvent parseNextEvent(ITmfTrace<T> trace, ITmfContext context) throws IOException;
-}
this(dataType, range, 0, nbRequested, blockSize, ExecutionType.FOREGROUND);
}
+ /**
+ * Request 'n' events of a given type for the given time range (high priority).
+ * Events are returned in blocks of the given size.
+ *
+ * @param dataType the requested data type
+ * @param range the time range of the requested events
+ * @param index the index of the first event to retrieve
+ * @param nbRequested the number of events requested
+ * @param blockSize the number of events per block
+ */
+ public TmfEventRequest(Class<T> dataType, TmfTimeRange range, int index, int nbRequested, int blockSize) {
+ this(dataType, range, index, nbRequested, blockSize, ExecutionType.FOREGROUND);
+ }
+
/**
* Request 'n' events of a given type for the given time range (given priority).
* Events are returned in blocks of the given size.
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009 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;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+
+/**
+ * <b><u>ITmfEventParser</u></b>
+ * <p>
+ */
+public interface ITmfEventParser<T extends ITmfEvent> {
+
+ /**
+ * Parses the trace event referenced by the context.
+ *
+ * @param context
+ * @return
+ */
+ public ITmfEvent parseEvent(ITmfContext context);
+
+}
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
/**
* <b><u>ITmfTrace</u></b>
* <p>
* The event stream structure in TMF. In its basic form, a trace has:
* <ul>
- * <li> the associated Eclipse resource
- * <li> the path to its location on the file system
+ * <li> an associated Eclipse resource
+ * <li> a path to its location on the file system
* <li> the type of the events it contains
* <li> the number of events it contains
* <li> the time range (span) of the events it contains
* </ul>
* Concrete ITmfTrace classes have to provide a parameter-less constructor and
- * an initialization method (initTace())if they are to be opened from the
- * Project View. Also, a validation (validate()) method has to be provided to
- * ensure that the trace is of the correct type.
+ * an initialization method (<i>initTrace</i>) if they are to be opened from
+ * the Project View. Also, a validation method (<i>validate</i>) has to be
+ * provided to ensure that the trace is of the correct type.
* <p>
* A trace can be accessed simultaneously from multiple threads by various
* application components. To avoid obvious multi-threading issues, the trace
* <p>
* <b>Example 1</b>: Process a whole trace
* <pre>
- * ITmfContext context = trace.seekLocationt(null);
- * ITmfEvent event = trace.getNextEvent(context);
+ * ITmfContext context = trace.seekEvent(0);
+ * ITmfEvent event = trace.getEvent(context);
* while (event != null) {
* processEvent(event);
- * event = trace.getNextEvent(context);
+ * event = trace.getEvent(context);
* }
* </pre>
* <b>Example 2</b>: Process 50 events starting from the 1000th event
* <pre>
* int nbEventsRead = 0;
* ITmfContext context = trace.seekEvent(1000);
- * ITmfEvent event = trace.getNextEvent(context);
+ * ITmfEvent event = trace.getEvent(context);
* while (event != null && nbEventsRead < 50) {
* nbEventsRead++;
* processEvent(event);
- * event = trace.getNextEvent(context);
+ * event = trace.getEvent(context);
* }
* </pre>
* <b>Example 3</b>: Process the events between 2 timestamps (inclusive)
* ITmfTimestamp startTime = ...;
* ITmfTimestamp endTime = ...;
* ITmfContext context = trace.seekEvent(startTime);
- * ITmfEvent event = trace.getNextEvent(context);
+ * ITmfEvent event = trace.getEvent(context);
* while (event != null && event.getTimestamp().compareTo(endTime) <= 0) {
* processEvent(event);
- * event = trace.getNextEvent(context);
+ * event = trace.getEvent(context);
* }
* </pre>
* A trace is also an event provider so it can process event requests
- * asynchronously (and coalesce compatible requests).
+ * asynchronously (and coalesce compatible, concurrent requests).
* <p>
* </pre>
- * <b>Example 4</b>: Process a whole trace
+ * <b>Example 4</b>: Process a whole trace (see ITmfEventRequest for variants)
* <pre>
* ITmfRequest request = new TmfEventRequest<MyEventType>(MyEventType.class) {
* @Override
* super.handleCompleted();
* }
* };
+ *
* fTrace.handleRequest(request);
* if (youWant) {
* request.waitForCompletion();
* </pre>
* @see ITmfEvent
* @see ITmfEventProvider
- * @see ITmfRequest
+ * @see ITmfEventRequest
*/
public interface ITmfTrace<T extends ITmfEvent> extends ITmfDataProvider<T> {
public double getLocationRatio(ITmfLocation<?> location);
// ------------------------------------------------------------------------
- // Seek operations (returning a reading context)
+ // SeekEvent operations (returning a trace context)
// ------------------------------------------------------------------------
/**
- * Position the trace at the specified location. The null location
- * is used to indicate that the first trace event is requested.
+ * Position the trace at the specified (trace specific) location.
+ * <p>
+ * A null location is interpreted as seeking for the first event of the
+ * trace.
* <p>
- * <ul>
- * <li> a <b>null</b> location returns the context of the first event
- * <li> an invalid location, including beyond the last event, returns a null context
- * </ul>
+ * If not null, the location requested must be valid otherwise the returned
+ * context is undefined (up to the implementation to recover if possible).
* <p>
- * @param location the trace specific location (null for 1st event)
+ * @param location the trace specific location
* @return a context which can later be used to read the corresponding event
*/
- public ITmfContext seekLocation(ITmfLocation<?> location);
+ public ITmfContext seekEvent(ITmfLocation<?> location);
/**
- * Position the trace at the event located at the specified ratio in the
- * trace file.
+ * Position the trace at the 'rank'th event in the trace.
* <p>
- * The notion of ratio (0.0 <= r <= 1.0) is trace specific and left
- * voluntarily vague. Typically, it would refer to the event proportional
- * rank (arguably more intuitive) or timestamp in the trace file.
+ * A rank <= 0 is interpreted as seeking for the first event of the
+ * trace.
+ * <p>
+ * If the requested rank is beyond the last trace event, the context
+ * returned will yield a null event if used in a subsequent read.
*
- * @param ratio the proportional 'rank' in the trace
+ * @param rank the event rank
* @return a context which can later be used to read the corresponding event
*/
- public ITmfContext seekLocation(double ratio);
+ public ITmfContext seekEvent(long rank);
/**
* Position the trace at the first event with the specified timestamp. If
public ITmfContext seekEvent(ITmfTimestamp timestamp);
/**
- * Position the trace at the 'rank'th event in the trace.
+ * Position the trace at the event located at the specified ratio in the
+ * trace file.
* <p>
- * If the requested rank is beyond the last trace event, the context
- * returned will yield a null event if used in a subsequent read.
+ * The notion of ratio (0.0 <= r <= 1.0) is trace specific and left
+ * voluntarily vague. Typically, it would refer to the event proportional
+ * rank (arguably more intuitive) or timestamp in the trace file.
*
- * @param rank the event rank
+ * @param ratio the proportional 'rank' in the trace
* @return a context which can later be used to read the corresponding event
*/
- public ITmfContext seekEvent(long rank);
+ public ITmfContext seekEvent(double ratio);
// ------------------------------------------------------------------------
// Read operations (returning an actual event)
* @param context the read context (will be updated)
* @return the event pointed to by the context
*/
- public ITmfEvent getNextEvent(ITmfContext context);
+ public ITmfEvent readEvent(ITmfContext context);
- /**
- * Return the event pointed by the supplied context (or null if no event
- * left) and *does not* update the context.
- *
- * @param context the read context
- * @return the next event in the stream
- */
- public ITmfEvent parseEvent(ITmfContext context);
+// /**
+// * Return the event pointed by the supplied context (or null if no event
+// * left) and *does not* update the context.
+// *
+// * @param context the read context
+// * @return the next event in the stream
+// */
+// public ITmfEvent parseEvent(ITmfContext context);
// ------------------------------------------------------------------------
+ //
// ------------------------------------------------------------------------
/**
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 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
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace;
+
+import java.util.Collections;
+import java.util.Vector;
+
+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.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
+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;
+
+/**
+ * <b><u>TmfTraceIndexer</u></b>
+ * <p>
+ * A simple trace indexer that builds 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).
+ */
+public class TmfCheckpointIndexer<T extends ITmfTrace<ITmfEvent>> implements ITmfTraceIndexer<T> {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The event trace to index
+ */
+ private final ITmfTrace<ITmfEvent> fTrace;
+
+ /**
+ * The interval between checkpoints
+ */
+ protected final int fCheckpointInterval;
+
+ /**
+ * The trace index. It is composed of checkpoints taken at intervals of
+ * fCheckpointInterval events.
+ */
+ protected final Vector<TmfCheckpoint> fTraceIndex;
+
+ // ------------------------------------------------------------------------
+ // Construction
+ // ------------------------------------------------------------------------
+
+ /**
+ * Basic constructor that uses the default trace block size as checkpoints
+ * intervals
+ *
+ * @param trace the trace to index
+ */
+ public TmfCheckpointIndexer(final ITmfTrace<ITmfEvent> trace) {
+ this(trace, TmfTrace.DEFAULT_BLOCK_SIZE);
+ }
+
+ /**
+ * Full trace indexer
+ *
+ * @param trace the trace to index
+ * @param interval the checkpoints interval
+ */
+ public TmfCheckpointIndexer(final ITmfTrace<ITmfEvent> trace, final int interval) {
+ fTrace = trace;
+ fCheckpointInterval = interval;
+ fTraceIndex = new Vector<TmfCheckpoint>();
+ }
+
+ // ------------------------------------------------------------------------
+ // ITmfTraceIndexer - buildIndex
+ // ------------------------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#indexTrace(boolean)
+ *
+ * The index is a list of contexts that point to events at regular interval
+ * (rank-wise) in the trace. After it is built, the index can be used to
+ * quickly access any event by rank or timestamp (using seekIndex()).
+ *
+ * The index is built simply by reading the trace
+ */
+ @Override
+ public void buildIndex(final boolean waitForCompletion) {
+
+ // The monitoring job
+ final Job job = new Job("Indexing " + fTrace.getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$
+ @Override
+ protected IStatus run(final IProgressMonitor monitor) {
+ while (!monitor.isCanceled()) {
+ try {
+ Thread.sleep(100);
+ } catch (final InterruptedException e) {
+ return Status.OK_STATUS;
+ }
+ }
+ monitor.done();
+ return Status.OK_STATUS;
+ }
+ };
+ job.schedule();
+
+ // Clear the checkpoints
+ fTraceIndex.clear();
+
+ // Build a background request for all the trace data. The index is
+ // updated as we go by getNextEvent().
+ final ITmfEventRequest<ITmfEvent> request = new TmfEventRequest<ITmfEvent>(ITmfEvent.class, TmfTimeRange.ETERNITY,
+ TmfDataRequest.ALL_DATA, fCheckpointInterval, ITmfDataRequest.ExecutionType.BACKGROUND)
+ {
+ ITmfTimestamp startTime = null;
+ ITmfTimestamp lastTime = null;
+
+ @Override
+ public void handleData(final ITmfEvent event) {
+ super.handleData(event);
+ if (event != null) {
+ final ITmfTimestamp timestamp = event.getTimestamp();
+ if (startTime == null) {
+ startTime = timestamp.clone();
+ }
+ lastTime = timestamp.clone();
+
+ // 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();
+ }
+
+ private void updateTraceStatus() {
+ if (getNbRead() != 0) {
+ signalNewTimeRange(startTime, lastTime);
+ }
+ }
+ };
+
+ // Submit the request and wait for completion if required
+ fTrace.sendRequest(request);
+ if (waitForCompletion) {
+ try {
+ request.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
+ // ------------------------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer#updateIndex(org.eclipse.linuxtools.tmf.core.trace.ITmfContext, org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp)
+ */
+ @Override
+ public synchronized void updateIndex(final ITmfContext context, final ITmfTimestamp timestamp) {
+ final long rank = context.getRank();
+ if ((rank % fCheckpointInterval) == 0) {
+ // Determine the table position
+ final long position = rank / fCheckpointInterval;
+ // Add new entry at proper location (if empty)
+ if (fTraceIndex.size() == position) {
+ final ITmfLocation<?> location = context.getLocation().clone();
+ fTraceIndex.add(new TmfCheckpoint(timestamp.clone(), location));
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // ITmfTraceIndexer - seekIndex
+ // ------------------------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer#seekIndex(org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp)
+ */
+ @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));
+ }
+
+ // Position the trace at the checkpoint
+ return seekCheckpoint(index);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer#seekIndex(long)
+ */
+ @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 seekCheckpoint(index);
+ }
+
+ /**
+ * Position the trace at the given checkpoint
+ *
+ * @param index
+ * the checkpoint index
+ * @return the corresponding context
+ */
+ private ITmfContext seekCheckpoint(int index) {
+ ITmfLocation<?> location;
+ synchronized (fTraceIndex) {
+ if (!fTraceIndex.isEmpty()) {
+ if (index >= fTraceIndex.size()) {
+ index = fTraceIndex.size() - 1;
+ }
+ location = fTraceIndex.elementAt(index).getLocation();
+ } else {
+ location = null;
+ }
+ }
+ final ITmfContext context = fTrace.seekEvent(location);
+ context.setRank(index * fCheckpointInterval);
+ return context;
+ }
+
+}
private String fPath;
/**
- * The cache page size AND trace checkpoints interval
+ * The cache page size
*/
protected int fCacheSize = DEFAULT_TRACE_CACHE_SIZE;
- // The set of event stream checkpoints
-// protected Vector<TmfCheckpoint> fCheckpoints = new Vector<TmfCheckpoint>();
-
- // The number of events collected
+ /**
+ * The number of events collected so far
+ */
protected long fNbEvents = 0;
// The time span of the event stream
*/
protected ITmfTraceIndexer<ITmfTrace<ITmfEvent>> fIndexer;
+ /**
+ * The trace parser
+ */
+ protected ITmfEventParser<ITmfEvent> fParser;
+
// ------------------------------------------------------------------------
// Construction
// ------------------------------------------------------------------------
@SuppressWarnings({ "unchecked", "rawtypes" })
public TmfTrace() {
super();
- fIndexer = new TmfTraceIndexer(this);
+ fIndexer = new TmfCheckpointIndexer(this);
}
/**
super();
fCacheSize = (cacheSize > 0) ? cacheSize : DEFAULT_TRACE_CACHE_SIZE;
fStreamingInterval = interval;
- fIndexer = (indexer != null) ? indexer : new TmfTraceIndexer(this, fCacheSize);
+ fIndexer = (indexer != null) ? indexer : new TmfCheckpointIndexer(this, fCacheSize);
initialize(resource, path, type);
}
throw new IllegalArgumentException();
fCacheSize = trace.getCacheSize();
fStreamingInterval = trace.getStreamingInterval();
- fIndexer = new TmfTraceIndexer(this);
+ fIndexer = new TmfCheckpointIndexer(this);
initialize(trace.getResource(), trace.getPath(), trace.getType());
}
+ // ------------------------------------------------------------------------
+ // ITmfTrace - Initializers
+ // ------------------------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#initTrace(org.eclipse.core.resources.IResource, java.lang.String, java.lang.Class)
+ */
+ @Override
+ public void initTrace(final IResource resource, final String path, final Class<T> type) throws FileNotFoundException {
+ initialize(resource, path, type);
+ fIndexer.buildIndex(false);
+ }
+
/**
* Initialize the trace common attributes and the base component.
*
super.init(traceName, type);
}
- // ------------------------------------------------------------------------
- // ITmfTrace - Initializers
- // ------------------------------------------------------------------------
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#initTrace(org.eclipse.core.resources.IResource, java.lang.String, java.lang.Class)
- */
- @Override
- public void initTrace(final IResource resource, final String path, final Class<T> type) throws FileNotFoundException {
- initialize(resource, path, type);
- fIndexer.buildIndex(false);
- }
-
/* (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(org.eclipse.core.resources.IProject, java.lang.String)
*
}
// ------------------------------------------------------------------------
- // ITmfTrace - Seek operations (returning a reading context)
+ // ITmfTrace - SeekEvent operations (returning a trace context)
// ------------------------------------------------------------------------
/* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp)
+ * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(long)
*/
@Override
- public synchronized ITmfContext seekEvent(final ITmfTimestamp timestamp) {
+ public synchronized ITmfContext seekEvent(final long rank) {
- // A null timestamp indicates to seek the first event
- if (timestamp == null)
- return seekLocation(null);
+ // A rank <= 0 indicates to seek the first event
+ if (rank <= 0)
+ return seekEvent((ITmfLocation<?>) null);
// Position the trace at the checkpoint
- final ITmfContext context = fIndexer.seekIndex(timestamp);
+ final ITmfContext context = fIndexer.seekIndex(rank);
// And locate the requested event context
- final ITmfContext nextEventContext = context.clone(); // Must use clone() to get the right subtype...
- ITmfEvent event = getNextEvent(nextEventContext);
- while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) {
- context.setLocation(nextEventContext.getLocation().clone());
- context.increaseRank();
- event = getNextEvent(nextEventContext);
+ long pos = context.getRank();
+ if (pos < rank) {
+ ITmfEvent event = readEvent(context);
+ while (event != null && ++pos < rank) {
+ event = readEvent(context);
+ }
}
return context;
}
/* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(long)
+ * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp)
*/
@Override
- public synchronized ITmfContext seekEvent(final long rank) {
+ public synchronized ITmfContext seekEvent(final ITmfTimestamp timestamp) {
- // A rank <= 0 indicates to seek the first event
- if (rank <= 0)
- return seekLocation(null);
+ // A null timestamp indicates to seek the first event
+ if (timestamp == null)
+ return seekEvent(0);
// Position the trace at the checkpoint
- final ITmfContext context = fIndexer.seekIndex(rank);
+ final ITmfContext context = fIndexer.seekIndex(timestamp);
// And locate the requested event context
- long pos = context.getRank();
- if (pos < rank) {
- ITmfEvent event = getNextEvent(context);
- while (event != null && ++pos < rank) {
- event = getNextEvent(context);
- }
+ final ITmfContext nextEventContext = context.clone(); // Must use clone() to get the right subtype...
+ ITmfEvent event = readEvent(nextEventContext);
+ while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) {
+ context.setLocation(nextEventContext.getLocation().clone());
+ context.increaseRank();
+ event = readEvent(nextEventContext);
}
return context;
}
// ------------------------------------------------------------------------
/* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#parseEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext)
- */
- @Override
- public synchronized ITmfEvent parseEvent(final ITmfContext context) {
- final ITmfContext tmpContext = context.clone();
- final ITmfEvent event = getNextEvent(tmpContext);
- return event;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getNextEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext)
+ * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#readEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext)
*/
@Override
- public synchronized ITmfEvent getNextEvent(final ITmfContext context) {
+ public synchronized ITmfEvent readEvent(final ITmfContext context) {
// parseEvent() does not update the context
- final ITmfEvent event = parseEvent(context);
+ final ITmfEvent event = fParser.parseEvent(context);
if (event != null) {
updateAttributes(context, event.getTimestamp());
context.setLocation(getCurrentLocation());
/**
* Hook for special event processing by the concrete class
- * (called by TmfTrace.getNextEvent())
+ * (called by TmfTrace.getEvent())
*
* @param event the event
*/
@SuppressWarnings("unchecked")
public T getNext(final ITmfContext context) {
if (context instanceof TmfContext)
- return (T) getNextEvent(context);
+ return (T) readEvent(context);
return null;
}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 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
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-import java.util.Collections;
-import java.util.Vector;
-
-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.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
-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;
-
-/**
- * <b><u>TmfTraceIndexer</u></b>
- * <p>
- * A simple trace indexer that builds 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).
- */
-public class TmfTraceIndexer<T extends ITmfTrace<ITmfEvent>> implements ITmfTraceIndexer<T> {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- /**
- * The event trace to index
- */
- private final ITmfTrace<ITmfEvent> fTrace;
-
- /**
- * The interval between checkpoints
- */
- protected final int fCheckpointInterval;
-
- /**
- * The trace index. It is composed of checkpoints taken at intervals of
- * fCheckpointInterval events.
- */
- protected final Vector<TmfCheckpoint> fTraceIndex;
-
- // ------------------------------------------------------------------------
- // Construction
- // ------------------------------------------------------------------------
-
- /**
- * Basic constructor that uses the default trace block size as checkpoints
- * intervals
- *
- * @param trace the trace to index
- */
- public TmfTraceIndexer(final ITmfTrace<ITmfEvent> trace) {
- this(trace, TmfTrace.DEFAULT_BLOCK_SIZE);
- }
-
- /**
- * Full trace indexer
- *
- * @param trace the trace to index
- * @param interval the checkpoints interval
- */
- public TmfTraceIndexer(final ITmfTrace<ITmfEvent> trace, final int interval) {
- fTrace = trace;
- fCheckpointInterval = interval;
- fTraceIndex = new Vector<TmfCheckpoint>();
- }
-
- // ------------------------------------------------------------------------
- // ITmfTraceIndexer - buildIndex
- // ------------------------------------------------------------------------
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#indexTrace(boolean)
- *
- * The index is a list of contexts that point to events at regular interval
- * (rank-wise) in the trace. After it is built, the index can be used to
- * quickly access any event by rank or timestamp (using seekIndex()).
- *
- * The index is built simply by reading the trace
- */
- @Override
- public void buildIndex(final boolean waitForCompletion) {
-
- // The monitoring job
- final Job job = new Job("Indexing " + fTrace.getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$
- @Override
- protected IStatus run(final IProgressMonitor monitor) {
- while (!monitor.isCanceled()) {
- try {
- Thread.sleep(100);
- } catch (final InterruptedException e) {
- return Status.OK_STATUS;
- }
- }
- monitor.done();
- return Status.OK_STATUS;
- }
- };
- job.schedule();
-
- // Clear the checkpoints
- fTraceIndex.clear();
-
- // Build a background request for all the trace data. The index is
- // updated as we go by getNextEvent().
- final ITmfEventRequest<ITmfEvent> request = new TmfEventRequest<ITmfEvent>(ITmfEvent.class, TmfTimeRange.ETERNITY,
- TmfDataRequest.ALL_DATA, fCheckpointInterval, ITmfDataRequest.ExecutionType.BACKGROUND)
- {
- ITmfTimestamp startTime = null;
- ITmfTimestamp lastTime = null;
-
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- if (event != null) {
- final ITmfTimestamp timestamp = event.getTimestamp();
- if (startTime == null) {
- startTime = timestamp.clone();
- }
- lastTime = timestamp.clone();
-
- // 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();
- }
-
- private void updateTraceStatus() {
- if (getNbRead() != 0) {
- notifyListeners(startTime, lastTime);
- }
- }
- };
-
- // Submit the request and wait for completion if required
- fTrace.sendRequest(request);
- if (waitForCompletion) {
- try {
- request.waitForCompletion();
- } catch (final InterruptedException e) {
- }
- }
- }
-
- private void notifyListeners(final ITmfTimestamp startTime, final ITmfTimestamp endTime) {
- fTrace.broadcast(new TmfTraceUpdatedSignal(fTrace, fTrace, new TmfTimeRange(startTime, endTime)));
- }
-
- // ------------------------------------------------------------------------
- // ITmfTraceIndexer - updateIndex
- // ------------------------------------------------------------------------
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer#updateIndex(org.eclipse.linuxtools.tmf.core.trace.ITmfContext, org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp)
- */
- @Override
- public synchronized void updateIndex(final ITmfContext context, final ITmfTimestamp timestamp) {
- final long rank = context.getRank();
- if ((rank % fCheckpointInterval) == 0) {
- // Determine the table position
- final long position = rank / fCheckpointInterval;
- // Add new entry at proper location (if empty)
- if (fTraceIndex.size() == position) {
- final ITmfLocation<?> location = context.getLocation().clone();
- fTraceIndex.add(new TmfCheckpoint(timestamp.clone(), location));
- }
- }
- }
-
- // ------------------------------------------------------------------------
- // ITmfTraceIndexer - seekIndex
- // ------------------------------------------------------------------------
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer#seekIndex(org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp)
- */
- @Override
- public synchronized ITmfContext seekIndex(final ITmfTimestamp timestamp) {
-
- // A null timestamp indicates to seek the first event
- if (timestamp == null)
- return fTrace.seekLocation(null);
-
- // 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));
- }
-
- // Position the trace at the checkpoint
- return seekCheckpoint(index);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer#seekIndex(long)
- */
- @Override
- public ITmfContext seekIndex(final long rank) {
-
- // A rank <= 0 indicates to seek the first event
- if (rank <= 0)
- return fTrace.seekLocation(null);
-
- // Find the checkpoint at or before the requested rank.
- final int index = (int) rank / fCheckpointInterval;
-
- // Position the trace at the checkpoint
- return seekCheckpoint(index);
- }
-
- /**
- * Position the trace at the given checkpoint
- *
- * @param index
- * the checkpoint index
- * @return the corresponding context
- */
- private ITmfContext seekCheckpoint(int index) {
- ITmfLocation<?> location;
- synchronized (fTraceIndex) {
- if (!fTraceIndex.isEmpty()) {
- if (index >= fTraceIndex.size()) {
- index = fTraceIndex.size() - 1;
- }
- location = fTraceIndex.elementAt(index).getLocation();
- } else {
- location = null;
- }
- }
- final ITmfContext context = fTrace.seekLocation(location);
- context.setRank(index * fCheckpointInterval);
- return context;
- }
-
-}
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
-import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
import org.eclipse.linuxtools.tmf.ui.tests.uml2sd.trace.TmfUml2SDTestTrace;
fParser = new TmfUml2SDTestTrace();
fTrace = setupTrace(fParser);
+ fParser.setTrace(fTrace);
IViewPart view;
try {
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public void selectExperiment(final boolean wait) {
+ fParser = new TmfUml2SDTestTrace();
fTrace = setupTrace(fParser);
+ fParser.setTrace(fTrace);
+
+// fTrace = setupTrace(fParser);
final ITmfTrace traces[] = new ITmfTrace[1];
traces[0] = fTrace;
import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.parser.ITmfEventParser;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
public class TmfUml2SDTestTrace implements ITmfEventParser<TmfEvent> {
+ ITmfTrace<TmfEvent> fEventStream;
+
+ public TmfUml2SDTestTrace() {
+ }
+
+ public TmfUml2SDTestTrace(ITmfTrace<TmfEvent> eventStream) {
+ fEventStream = eventStream;
+ }
+
+ public void setTrace(ITmfTrace<TmfEvent> eventStream) {
+ fEventStream = eventStream;
+ }
+
@Override
@SuppressWarnings({ "unchecked", "nls" })
- public TmfEvent parseNextEvent(ITmfTrace<TmfEvent> eventStream, ITmfContext context) throws IOException {
- if (! (eventStream instanceof TmfTraceStub)) {
+ public TmfEvent parseEvent(ITmfContext context) {
+ if (! (fEventStream instanceof TmfTraceStub)) {
return null;
}
// Highly inefficient...
- RandomAccessFile stream = ((TmfTraceStub) eventStream).getStream();
+ RandomAccessFile stream = ((TmfTraceStub) fEventStream).getStream();
// String name = eventStream.getName();
// name = name.substring(name.lastIndexOf('/') + 1);
long location = 0;
if (context != null)
location = ((TmfLocation<Long>) (context.getLocation())).getLocation();
- stream.seek(location);
try {
+ stream.seek(location);
+
long ts = stream.readLong();
String source = stream.readUTF();
String type = stream.readUTF();
fields[2] = new TmfEventField("signal", signal);
ITmfEventField tmfContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, content, fields);
- TmfEvent tmfEvent = new TmfEvent(eventStream, new TmfTimestamp(ts, -9), source, tmfEventType, tmfContent, reference);
+ TmfEvent tmfEvent = new TmfEvent(fEventStream, new TmfTimestamp(ts, -9), source, tmfEventType, tmfContent, reference);
return tmfEvent;
- } catch (EOFException e) {
+ } catch (final EOFException e) {
+ } catch (final IOException e) {
}
return null;
}
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile;\r
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;\r
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;\r
import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;\r
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;\r
import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;\r
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;\r
\r
-public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> {\r
+public class CustomTxtTrace extends TmfTrace<CustomTxtEvent> implements ITmfEventParser<CustomTxtEvent> {\r
\r
private static final TmfLocation<Long> NULL_LOCATION = new TmfLocation<Long>((Long) null);\r
private static final int DEFAULT_CACHE_SIZE = 100;\r
}\r
\r
@Override\r
- public TmfContext seekLocation(final ITmfLocation<?> location) {\r
+ public TmfContext seekEvent(final ITmfLocation<?> location) {\r
final CustomTxtTraceContext context = new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.INITIAL_RANK);\r
if (NULL_LOCATION.equals(location) || !new File(getPath()).isFile())\r
return context;\r
}\r
\r
@Override\r
- public TmfContext seekLocation(final double ratio) {\r
+ public TmfContext seekEvent(final double ratio) {\r
BufferedRandomAccessFile raFile = null;\r
try {\r
raFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$\r
pos--;\r
}\r
final ITmfLocation<?> location = new TmfLocation<Long>(pos);\r
- final TmfContext context = seekLocation(location);\r
+ final TmfContext context = seekEvent(location);\r
context.setRank(ITmfContext.UNKNOWN_RANK);\r
return context;\r
} catch (final FileNotFoundException e) {\r
}\r
\r
@Override\r
- public synchronized TmfEvent getNextEvent(final ITmfContext context) {\r
+ public synchronized TmfEvent readEvent(final ITmfContext context) {\r
final ITmfContext savedContext = context.clone();\r
final TmfEvent event = parseEvent(context);\r
if (event != null) {\r
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile;\r
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;\r
+import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;\r
import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;\r
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;\r
import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;\r
import org.xml.sax.SAXException;\r
import org.xml.sax.SAXParseException;\r
\r
-public class CustomXmlTrace extends TmfTrace<CustomXmlEvent> {\r
+public class CustomXmlTrace extends TmfTrace<CustomXmlEvent> implements ITmfEventParser<CustomXmlEvent> {\r
\r
private static final TmfLocation<Long> NULL_LOCATION = new TmfLocation<Long>((Long) null);\r
private static final int DEFAULT_CACHE_SIZE = 100;\r
}\r
\r
@Override\r
- public TmfContext seekLocation(final ITmfLocation<?> location) {\r
+ public TmfContext seekEvent(final ITmfLocation<?> location) {\r
final CustomXmlTraceContext context = new CustomXmlTraceContext(NULL_LOCATION, ITmfContext.INITIAL_RANK);\r
if (NULL_LOCATION.equals(location) || !new File(getPath()).isFile())\r
return context;\r
}\r
\r
@Override\r
- public TmfContext seekLocation(final double ratio) {\r
+ public TmfContext seekEvent(final double ratio) {\r
BufferedRandomAccessFile raFile = null;\r
try {\r
raFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$\r
pos--;\r
}\r
final ITmfLocation<?> location = new TmfLocation<Long>(pos);\r
- final TmfContext context = seekLocation(location);\r
+ final TmfContext context = seekEvent(location);\r
context.setRank(ITmfContext.UNKNOWN_RANK);\r
return context;\r
} catch (final FileNotFoundException e) {\r
}\r
\r
@Override\r
- public synchronized TmfEvent getNextEvent(final ITmfContext context) {\r
+ public synchronized TmfEvent readEvent(final ITmfContext context) {\r
final ITmfContext savedContext = context.clone();\r
final TmfEvent event = parseEvent(context);\r
if (event != null) {\r
}\r
while (true) {\r
long rank = context.getRank();\r
- ITmfEvent event = trace.getNextEvent(context);\r
+ ITmfEvent event = trace.readEvent(context);\r
if (event == null) {\r
done = true;\r
break;\r
if (interrupted)\r
return;\r
long rank = fContext.getRank();\r
- ITmfEvent event = trace.getNextEvent(fContext);\r
+ ITmfEvent event = trace.readEvent(fContext);\r
if (event == null) {\r
break;\r
}\r
}\r
\r
private void setTopPosition(double ratio) {\r
- fBottomContext = fTrace.seekLocation(ratio);\r
+ fBottomContext = fTrace.seekEvent(ratio);\r
if (fBottomContext == null) {\r
return;\r
}\r
while (fTopLineIndex < 0) {\r
ITmfLocation<?> endLocation = fLines.get(0).location;\r
firstRatio = Math.max(0, firstRatio - delta);\r
- ITmfContext context = fTrace.seekLocation(firstRatio);\r
+ ITmfContext context = fTrace.seekEvent(firstRatio);\r
ITmfLocation<?> location;\r
int index = 0;\r
long rank = 0;\r
while (!context.getLocation().equals(endLocation)) {\r
location = context.getLocation().clone();\r
- ITmfEvent event = fTrace.getNextEvent(context);\r
+ ITmfEvent event = fTrace.readEvent(context);\r
if (event == null) {\r
break;\r
}\r
fBottomContext = fTrace.seekEvent(0);\r
} else {\r
//fBottomContext = fTrace.seekEvent(fLines.get(fLines.size() - 1).rank + 1);\r
- fBottomContext = fTrace.seekLocation(fLines.get(fLines.size() - 1).location);\r
- fTrace.getNextEvent(fBottomContext);\r
+ fBottomContext = fTrace.seekEvent(fLines.get(fLines.size() - 1).location);\r
+ fTrace.readEvent(fBottomContext);\r
}\r
if (fBottomContext == null) {\r
break;\r
}\r
long rank = fBottomContext.getRank();\r
ITmfLocation<?> location = fBottomContext.getLocation() != null ? fBottomContext.getLocation().clone() : null;\r
- ITmfEvent event = fTrace.getNextEvent(fBottomContext);\r
+ ITmfEvent event = fTrace.readEvent(fBottomContext);\r
if (event == null) {\r
break;\r
}\r