Bundle-Version: 0.0.1
Bundle-Vendor: Eclipse
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.junit4;bundle-version="4.5.0",
- org.eclipse.linuxtools.lttng;bundle-version="0.0.1",
- org.eclipse.linuxtools.tmf;bundle-version="0.0.1"
+Require-Bundle: org.eclipse.linuxtools.lttng;bundle-version="0.0.1",
+ org.eclipse.linuxtools.tmf;bundle-version="0.0.1",
+ org.junit;bundle-version="3.8.2"
package org.eclipse.linuxtools.lttng.event;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- LttngTimestampTest.class,
- LttngEventFieldTest.class,
- LttngEventFormatTest.class,
- LttngEventContentTest.class,
- LttngEventReferenceTest.class,
- LttngEventTypeTest.class,
- LttngEventTest.class
-})
-
-public class AllLttngTests {
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+public final class AllLttngTests extends TestCase {
+ public static TestSuite suite() {
+ TestSuite suite = new TestSuite("Testing JNI");
+
+ suite.addTestSuite(LttngTimestampTest.class);
+ suite.addTestSuite(LttngEventFieldTest.class);
+ suite.addTestSuite(LttngEventContentTest.class);
+ suite.addTestSuite(LttngEventReferenceTest.class);
+ suite.addTestSuite(LttngEventTypeTest.class);
+ suite.addTestSuite(LttngEventTest.class);
+
+ return suite;
+ }
}
package org.eclipse.linuxtools.lttng.event;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.fail;
-
import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
+import junit.framework.TestCase;
/*
Functions tested here :
public String toString()
*/
-public class LttngEventContentTest {
+public class LttngEventContentTest extends TestCase {
private final static boolean skipIndexing=true;
private final static boolean waitForCompletion=true;
private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
return tmpEventContent;
}
- @Test
public void testConstructors() {
+ LttngEvent testEvent = null;
LttngEventContent testContent = null;
@SuppressWarnings("unused")
LttngEventContent testContent2 = null;
- LttngEventFormat testFormat = new LttngEventFormat(new String[1]);
LttngEventField[] testFields = new LttngEventField[1];
- testFields[0] = new LttngEventField("test", "test");
+ testFields[0] = new LttngEventField(testContent2, "test");
// Default construction with good argument
try {
- testContent = new LttngEventContent(testFormat);
+ testContent = new LttngEventContent();
}
catch( Exception e) {
fail("Construction with format failed!");
// Construction with good parameters
try {
- testContent = new LttngEventContent(testFormat, "test", testFields);
+ testContent = new LttngEventContent(testEvent);
}
catch( Exception e) {
fail("Construction with format, content and fields failed!");
// Copy constructor with correct parameters
try {
- testContent = new LttngEventContent(testFormat);
+ testContent = new LttngEventContent(testEvent);
testContent2 = new LttngEventContent(testContent);
}
catch( Exception e) {
}
- @Test
public void testGetter() {
LttngEventContent testContent = null;
LTTngTrace tmpStream = null;
LttngEvent tmpEvent = null;
TmfTraceContext tmpContext = null;
- //*** Basic (very bad) interface ***
- testContent = prepareToTest();
- // getFieldS()
- assertNotSame("getFields() returned null!",null,testContent.getFields().toString());
- // getField(int)
- assertEquals("getField(int) returned unexpected result!",firstEventContentFirstField, testContent.getField(0).toString());
-
-
- //*** Upgraded (better) interface ***
// Require an event
tmpStream = initializeEventStream();
tmpContext = new TmfTraceContext(null, null, 0);
testContent = prepareToTest();
// getFieldS()
- assertNotSame("getFields(event) returned null!",null,testContent.getFields(tmpEvent) );
+ assertNotSame("getFields() returned null!",null,testContent.getFields() );
// getField(int)
- assertEquals("getField(int, event) returned unexpected result!",firstEventContentFirstField, testContent.getField(0, tmpEvent).toString());
+ assertEquals("getField(int) returned unexpected result!",firstEventContentFirstField, testContent.getField(0).toString());
// Second event past metadata should have more fields
tmpEvent = (LttngEvent)tmpStream.parseEvent(tmpContext);
- //*** Basic (very bad) interface ***
- testContent = (LttngEventContent)tmpEvent.getContent();
// getFieldS()
- assertNotSame("getFields() returned null!",null,testContent.getFields().toString());
+ assertNotSame("getFields() returned null!",null,testContent.getFields() );
// getField(int)
assertEquals("getField(int) returned unexpected result!",secondEventContentSecondField, testContent.getField(1).toString());
-
- //*** Upgraded (better) interface ***
- // getFieldS()
- assertNotSame("getFields(event) returned null!",null,testContent.getFields(tmpEvent) );
- // getField(int)
- assertEquals("getField(int, event) returned unexpected result!",secondEventContentSecondField, testContent.getField(1, tmpEvent).toString());
-
}
- @Test
public void testToString() {
LttngEventContent tmpContent = prepareToTest();
package org.eclipse.linuxtools.lttng.event;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.fail;
+
import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
+import junit.framework.TestCase;
/*
Functions tested here :
*/
-public class LttngEventFieldTest {
+public class LttngEventFieldTest extends TestCase {
private final static boolean skipIndexing=true;
private final static boolean waitForCompletion=true;
private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
return tmpField;
}
- @Test
public void testConstructors() {
+ LttngEventContent testContent = null;
LttngEventField testField = null;
@SuppressWarnings("unused")
LttngEventField testField2 = null;
// Default construction with good argument
try {
- testField = new LttngEventField("test", "test");
+ testField = new LttngEventField(testContent, "test", "test");
}
catch( Exception e) {
fail("Default construction failed!");
// Copy constructor with correct parameters
try {
- testField = new LttngEventField("test", "test");
+ testField = new LttngEventField(testContent, "test", "test");
testField2 = new LttngEventField(testField);
}
catch( Exception e) {
}
-
- @Test
public void testGetter() {
// *** To "really" test the field, we will get a real field from LTTngTrace
LttngEventField testField = (LttngEventField)tmpStream.parseEvent( new TmfTraceContext(null, null, 0) ).getContent().getField(0);
assertNotSame("getField is null!",null,testField);
- assertEquals("getName() returned unexpected result!",firstEventName, testField.getName().toString());
- assertEquals("getValue() returned unexpected result!",firstEventValue, testField.getValue().toString());
+ assertTrue("getName() returned unexpected result!",firstEventName.equals(testField.getId().toString()));
+ assertTrue("getValue() returned unexpected result!",firstEventValue.equals(testField.getValue().toString()));
}
- @Test
public void testToString() {
LttngEventField tmpField = prepareToTest();
+++ /dev/null
-package org.eclipse.linuxtools.lttng.event;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.fail;
-
-import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
-import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
-
-/*
- Functions tested here :
- public LttngEventFormat()
- public String[] getLabels(LttngEvent thisEvent)
- public LttngEventField[] parse(LttngEvent thisEvent)
- public LttngEventField[] parse(HashMap<String, Object> parsedEvents)
- public LttngEventField[] parse(String uselessContent)
-
- */
-
-public class LttngEventFormatTest {
- private final static boolean skipIndexing=true;
- private final static boolean waitForCompletion=true;
- private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
-
- private final static long timestampAfterMetadata = 952090116049L;
-
- private final static String secondEventFirstField = "loglevel";
- private final static String secondEventSecondField = "string";
- //private final static String secondEventThirdField = "ip";
-
- private final static String secondEventThirdFieldParsedValue = "ip:0xc04f402c";
-
-
- private LTTngTrace initializeEventStream() {
- LTTngTrace tmpStream = null;
- try {
- tmpStream = new LTTngTrace(tracepath1, waitForCompletion, skipIndexing);
- }
- catch (Exception e) {
- fail("ERROR : Could not open " + tracepath1 + ". Test failed!" );
- }
-
- return tmpStream;
- }
-
-
- private LttngEventFormat prepareToTest() {
- LttngEventFormat tmpEventFormat = null;
-
- // This trace should be valid
- try {
- LTTngTrace tmpStream = initializeEventStream();
- tmpEventFormat = (LttngEventFormat)tmpStream.parseEvent( new TmfTraceContext(null, null, 0) ).getContent().getFormat();
- }
- catch (Exception e) {
- fail("ERROR : Failed to get format!");
- }
-
- return tmpEventFormat;
- }
-
- @Test
- public void testConstructors() {
- LttngEventFormat testFormat = null;
- @SuppressWarnings("unused")
- LttngEventFormat testFormat2 = null;
-
-
- // Default construction with good argument
- try {
- testFormat = new LttngEventFormat(new String[1]);
- }
- catch( Exception e) {
- fail("Construction failed!");
- }
-
- // Copy constructor
- try {
- testFormat = new LttngEventFormat(new String[1]);
- testFormat2 = new LttngEventFormat(testFormat);
- }
- catch( Exception e) {
- fail("Copy construction failed!");
- }
-
- }
-
-
- @Test
- public void testGetter() {
- LttngEventFormat testFormat = null;
- LTTngTrace tmpStream = null;
- LttngEvent tmpEvent = null;
- TmfTraceContext tmpContext = new TmfTraceContext(null, null, 0);
-
- //*** Position ourself to the second event to have something interesting to test with ***
-
- tmpStream = initializeEventStream();
- // Skip first events and seek to events past metadata
- tmpContext= tmpStream.seekLocation(new LttngTimestamp(timestampAfterMetadata) );
- // Skip first one
- tmpEvent = (LttngEvent)tmpStream.parseEvent(tmpContext);
- // Second event should have more fields
- tmpEvent = (LttngEvent)tmpStream.parseEvent(tmpContext);
- // Get a real format from the event
- testFormat = (LttngEventFormat)tmpEvent.getContent().getFormat();
-
- // Test getLabels()
- assertEquals("Label not as expected!",secondEventFirstField,testFormat.getLabels()[0].toString());
- assertEquals("Label not as expected!",secondEventSecondField,testFormat.getLabels()[1].toString());
-
-
- // Test different parse()
- // parse(event)
- assertNotSame("parse() returned null!",null, testFormat.parse(tmpEvent));
- assertEquals("Parsed field not as expected!",secondEventThirdFieldParsedValue,testFormat.parse(tmpEvent)[2].toString());
-
- // parse(hashmap)
- assertNotSame("parse() returned null!",null, testFormat.parse(tmpEvent.convertEventTmfToJni().parseAllFields()));
- assertEquals("Parsed field not as expected!",secondEventThirdFieldParsedValue,testFormat.parse(tmpEvent.convertEventTmfToJni().parseAllFields())[2].toString());
-
-
- // parse(string)
- System.out.println(tmpEvent.getContent().getContent().toString());
- assertNotSame("parse() returned null!",null, testFormat.parse(tmpEvent.getContent().getContent().toString()));
- assertEquals("Parsed field not as expected!",secondEventThirdFieldParsedValue,testFormat.parse(tmpEvent.getContent().getContent())[2].toString());
- }
-
- @Test
- public void testToString() {
- LttngEventFormat tmpFormat = prepareToTest();
-
- // Just make sure toString() does not return null or the java reference
- assertNotSame("toString returned null",null, tmpFormat.toString() );
- assertNotSame("toString is not overridded!", tmpFormat.getClass().getName() + '@' + Integer.toHexString(tmpFormat.hashCode()), tmpFormat.toString() );
- }
-
-}
package org.eclipse.linuxtools.lttng.event;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
+import junit.framework.TestCase;
/*
Functions tested here :
public String toString()
*/
-public class LttngEventReferenceTest {
+public class LttngEventReferenceTest extends TestCase {
private final static boolean skipIndexing=true;
private final static boolean waitForCompletion=true;
private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
return tmpEventRef;
}
-
- @Test
+
public void testConstructors() {
LttngEventReference testRef = null;
@SuppressWarnings("unused")
}
- @Test
public void testGetter() {
LttngEventReference tmpRef = prepareToTest();
assertEquals("Content not what expected!",firstEventReference,tmpRef.getTracepath());
}
- @Test
public void testToString() {
LttngEventReference tmpRef = prepareToTest();
package org.eclipse.linuxtools.lttng.event;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
import org.eclipse.linuxtools.lttng.jni.JniEvent;
import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
import org.eclipse.linuxtools.tmf.event.TmfEventSource;
import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
+import junit.framework.TestCase;
/*
Functions tested here :
*/
-public class LttngEventTest {
+public class LttngEventTest extends TestCase {
private final static boolean skipIndexing=true;
private final static boolean waitForCompletion=true;
private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
return tmpEvent;
}
- @Test
public void testConstructors() {
LTTngTrace testStream1 = null;
LttngEvent testAnotherEvent = null;
LttngTimestamp testTime = null;
TmfEventSource testSource = null;
- LttngEventFormat testFormat = null;
LttngEventType testType = null;
LttngEventContent testContent = null;
LttngEventReference testReference = null;
JniEvent testJniEvent = null;
-
+ String[] testMarkerFields = null;
+
// This need to work if we want to perform tests
try {
// In order to test LttngEvent, we need all these constructors/functions to work.
// Make sure to run their unit tests first!
+ testMarkerFields = new String[1];
testStream1 = new LTTngTrace(tracepath1, waitForCompletion, skipIndexing);
testEvent = null;
testTime = new LttngTimestamp(0L);
testSource = new TmfEventSource("test");
- testFormat = new LttngEventFormat(new String[1]);
- testType = new LttngEventType("test", 0, "test", testFormat);
- testContent = new LttngEventContent(testFormat);
+ testType = new LttngEventType("test", 0L, "test", testMarkerFields);
+ testContent = new LttngEventContent(testEvent);
testReference = new LttngEventReference("test", "test");
testJniEvent = testStream1.getCurrentJniTrace().findNextEvent();
}
}
-
- @Test
public void testGetter() {
LttngEvent testEvent = prepareToTest();
assertEquals("CpuId not what expected!",eventCpu,testEvent.getCpuId());
assertEquals("Marker not what expected!",eventMarker,testEvent.getMarkerName());
assertEquals("Content not what expected!",eventContent,testEvent.getContent().getContent());
- assertTrue("Reference not what expected!",((String)testEvent.getReference().getValue()).contains(eventReference) );
+ assertTrue("Reference not what expected!",((String)testEvent.getReference().getReference()).contains(eventReference) );
}
- @Test
public void testConversion() {
JniEvent tmpJniEvent = null;
LttngEvent testEvent = null;
}
- @Test
public void testToString() {
LttngEvent tmpEvent = prepareToTest();
package org.eclipse.linuxtools.lttng.event;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.fail;
-
import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
+import junit.framework.TestCase;
/*
Functions tested here :
public String toString()
*/
-public class LttngEventTypeTest {
+public class LttngEventTypeTest extends TestCase {
private final static boolean skipIndexing=true;
private final static boolean waitForCompletion=true;
private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
return tmpEventType;
}
-
- @Test
+
public void testConstructors() {
LttngEventType tmpEventType = null;
@SuppressWarnings("unused")
// Default construction with good argument
try {
- tmpEventType = new LttngEventType("test", 0L, "test", new LttngEventFormat(new String[1]));
+ tmpEventType = new LttngEventType("test", 0L, "test", new String[1]);
}
catch( Exception e) {
fail("Construction failed!");
// Copy constructor
try {
- tmpEventType = new LttngEventType("test", 0L, "test", new LttngEventFormat(new String[1]));
+ tmpEventType = new LttngEventType("test", 0L, "test", new String[1]);
tmpEventType2 = new LttngEventType(tmpEventType);
}
catch( Exception e) {
}
- @Test
public void testGetter() {
LttngEventType tmpEventType = prepareToTest();
- assertEquals("Channel name not what was expected!",firstEventChannel,(String)tmpEventType.getChannelName() );
- assertEquals("Cpu Id not what was expected!",firstEventCpu,tmpEventType.getCpuId() );
- assertEquals("Marker Name not what was expected!",firstEventMarker,(String)tmpEventType.getMarkerName() );
- // Just test the non-nullity of format
- assertNotSame("getFormat returned null",null, tmpEventType.getFormat() );
+ assertTrue("Channel name not what was expected!",firstEventChannel.equals((String)tmpEventType.getTracefileName()) );
+ assertTrue("Cpu Id not what was expected!",firstEventCpu == tmpEventType.getCpuId() );
+ assertTrue("Marker Name not what was expected!",firstEventMarker.equals((String)tmpEventType.getMarkerName()) );
+ // Just test the non-nullity of labels
+ assertNotSame("getFormat returned null",null, tmpEventType.getLabels() );
}
- @Test
public void testToString() {
LttngEventType tmpEventType = prepareToTest();
package org.eclipse.linuxtools.lttng.event;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.fail;
-
import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
+import junit.framework.TestCase;
/*
Functions tested here :
public String toString()
*/
-public class LttngTimestampTest {
+public class LttngTimestampTest extends TestCase {
private final static boolean skipIndexing=true;
private final static boolean waitForCompletion=true;
private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
return tmpTime;
}
-
- @Test
+
public void testConstructors() {
LttngTimestamp tmpTime = null;
@SuppressWarnings("unused")
}
- @Test
public void testGetter() {
LttngTimestamp tmpTime = prepareToTest();
}
- @Test
public void testToString() {
LttngTimestamp tmpTime = prepareToTest();
package org.eclipse.linuxtools.lttng.jni;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- JniTraceTest.class,
- JniTracefileTest.class,
- JniEventTest.class,
- JniMarkerTest.class,
- JniMarkerFieldTest.class
-})
-
-public class AllJniTests {
-
-}
+public final class AllJniTests extends TestCase {
+ public static TestSuite suite() {
+ TestSuite suite = new TestSuite("Testing JNI");
+
+ suite.addTestSuite(JniTraceTest.class);
+ suite.addTestSuite(JniTracefileTest.class);
+ suite.addTestSuite(JniEventTest.class);
+ suite.addTestSuite(JniMarkerTest.class);
+ suite.addTestSuite(JniMarkerFieldTest.class);
+
+ return suite;
+ }
+}
\ No newline at end of file
*/
package org.eclipse.linuxtools.lttng.jni;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
+import junit.framework.TestCase;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.junit.Test;
-
/**
* @author alvaro
*
*/
-public class Combinations {
+public class Combinations extends TestCase {
+ private final static boolean printLttDebug = false;
+
private final static String tracepath="traceset/trace-618339events-1293lost-1cpu";
private final static String eventName = "syscall_state";
JniEvent tmpEvent = null;
// This trace should be valid
try {
- tmpEvent = new JniTrace(tracepath).requestEventByName(eventName);
+ tmpEvent = new JniTrace(tracepath, printLttDebug).requestEventByName(eventName);
} catch (JniException e) {
}
return tmpEvent;
}
-
- @Test
+
public void testGetSpecEventFields() {
JniEvent event = prepareEventToTest();
JniMarker dmarker = event.requestEventMarker();
}
- @Test
public void testEventsLoop() {
JniTrace trace = null;
JniEvent event = null;
try {
- trace = new JniTrace(tracepath);
+ trace = new JniTrace(tracepath, printLttDebug);
} catch (JniException e) {
e.printStackTrace();
}
package org.eclipse.linuxtools.lttng.jni;
-import static org.junit.Assert.*;
-import org.junit.Test;
+import junit.framework.TestCase;
-public class JniEventTest
+public class JniEventTest extends TestCase
{
+ private final static boolean printLttDebug = false;
+
private final static String tracepath="traceset/trace-618339events-1293lost-1cpu";
private final static String eventName="kernel0";
// This trace should be valid
try {
- tmpEvent = new JniTrace(tracepath).requestEventByName(eventName);
+ tmpEvent = new JniTrace(tracepath, printLttDebug).requestEventByName(eventName);
}
catch( JniException e) { }
}
- @Test
public void testEventConstructors() {
JniTracefile testTracefile = null;
// This trace should be valid and will be used in test
try {
- testTracefile = new JniTrace(tracepath).requestTracefileByName(eventName);
+ testTracefile = new JniTrace(tracepath, printLttDebug).requestTracefileByName(eventName);
}
catch( JniException e) { }
}
- @Test
public void testPrintAndToString() {
JniEvent testEvent = prepareEventToTest();
}
- @Test
public void testEventDisplacement() {
int readValue = -1;
assertEquals("readNextEvent() event timestamp is incoherent (test #2)",timestampToSeekTest1,testEvent.getEventTime().getTime() );
}
- @Test
public void testGetSet() {
JniEvent testEvent = prepareEventToTest();
assertNotNull("getParentTracefile returned null", testEvent.getParentTracefile() );
}
- @Test
public void testRequestFunctions() {
JniEvent testEvent = prepareEventToTest();
}
- @Test
public void testParseAllFieldsFunctions() {
JniEvent testEvent = prepareEventToTest();
assertNotNull("parseAllFields returned null",testEvent.parseAllFields() );
}
- @Test
public void testParseFieldByIdFunctions() {
JniEvent testEvent = prepareEventToTest();
package org.eclipse.linuxtools.lttng.jni;
-import static org.junit.Assert.*;
-import org.junit.Test;
+import junit.framework.TestCase;
/*
Functions tested here :
public void printMarkerFieldInformation()
*/
-public class JniMarkerFieldTest
+public class JniMarkerFieldTest extends TestCase
{
+ private final static boolean printLttDebug = false;
+
private final static String tracepath="traceset/trace-618339events-1293lost-1cpu";
private final static String eventName="kernel0";
// This trace should be valid
// We will read the first 2 event to have something interesting to test on
try {
- tmpEvent = new JniTrace(tracepath).requestEventByName(eventName);
+ tmpEvent = new JniTrace(tracepath, printLttDebug).requestEventByName(eventName);
tmpEvent.readNextEvent();
tmpEvent.readNextEvent();
return tmpMarkerField;
}
-
- @Test
public void testEventConstructors() {
JniMarker tmpMarker = null;
// This event should be valid and will be used in test
try {
- tmpMarker = new JniTrace(tracepath).requestEventByName(eventName).requestEventMarker();
+ tmpMarker = new JniTrace(tracepath, printLttDebug).requestEventByName(eventName).requestEventMarker();
}
catch( JniException e) { }
}
- @Test
public void testGetSet() {
JniMarkerField testMarkerField = prepareMarkerFieldToTest();
assertNotSame("getMarkerFieldPtr is 0",0,testMarkerField.getMarkerFieldPtr() );
}
- @Test
public void testPrintAndToString() {
JniMarkerField testMarkerField = prepareMarkerFieldToTest();
package org.eclipse.linuxtools.lttng.jni;
-import static org.junit.Assert.*;
-import org.junit.Test;
+import junit.framework.TestCase;
/*
Functions tested here :
public void printMarkerInformation()
*/
-public class JniMarkerTest
+public class JniMarkerTest extends TestCase
{
+ private final static boolean printLttDebug = false;
+
private final static String tracepath="traceset/trace-618339events-1293lost-1cpu";
private final static String eventName="kernel0";
// This trace should be valid
// We will read the second event to have something interesting to test on
try {
- tmpEvent = new JniTrace(tracepath).requestEventByName(eventName);
+ tmpEvent = new JniTrace(tracepath, printLttDebug).requestEventByName(eventName);
tmpEvent.readNextEvent();
tmpMarker = tmpEvent.requestEventMarker();
return tmpMarker;
}
-
- @Test
public void testEventConstructors() {
JniEvent tmpEvent = null;
// This event should be valid and will be used in test
try {
- tmpEvent = new JniTrace(tracepath).requestEventByName(eventName);
+ tmpEvent = new JniTrace(tracepath, printLttDebug).requestEventByName(eventName);
}
catch( JniException e) { }
}
- @Test
public void testGetSet() {
JniMarker testMarker = prepareMarkerToTest();
assertNotSame("getMarkerPtr is 0",0,testMarker.getMarkerPtr() );
}
- @Test
public void testPrintAndToString() {
JniMarker testMarker = prepareMarkerToTest();
package org.eclipse.linuxtools.lttng.jni;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.fail;
-
-import org.junit.Test;
+import junit.framework.TestCase;
/*
Functions tested here :
*/
-public class JniTraceTest
+public class JniTraceTest extends TestCase
{
+ private final static boolean printLttDebug = false;
+
private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
private final static String tracepath2="traceset/trace-1021events-nolost-1cpu";
private final static String wrongTracePath="/somewhere/that/does/not/exist";
// This trace should be valid
try {
- tmpTrace = new JniTrace(tracepath1);
+ tmpTrace = new JniTrace(tracepath1, printLttDebug);
}
catch( JniException e) { }
return tmpTrace;
}
- @Test
public void testTraceConstructors() {
JniTrace testTrace1 = null;
@SuppressWarnings("unused")
// Test constructor with argument on a wrong tracepath
try {
- testTrace1 = new JniTrace(wrongTracePath);
+ testTrace1 = new JniTrace(wrongTracePath, printLttDebug);
fail("Construction with wrong tracepath should fail!");
}
catch( JniException e) {
// Test constructor with argument on a correct tracepath
try {
- testTrace1 = new JniTrace(tracepath1);
+ testTrace1 = new JniTrace(tracepath1, printLttDebug);
}
catch( JniException e) {
fail("Construction with correct tracepath failed!");
// Test copy constructor that take a pointer with a good pointer
try {
- testTrace1 = new JniTrace( new Jni_C_Pointer(0) );
+ testTrace1 = new JniTrace( new Jni_C_Pointer(0), printLttDebug);
fail("Construction with wrong pointer should fail!");
}
catch( JniException e) {
// Test copy constructor that take a pointer with a good pointer
try {
- testTrace1 = new JniTrace(tracepath1); // This trace should be valid
- testTrace2 = new JniTrace( testTrace1.getTracePtr() );
+ testTrace1 = new JniTrace(tracepath1, printLttDebug); // This trace should be valid
+ testTrace2 = new JniTrace( testTrace1.getTracePtr(), printLttDebug);
}
catch( JniException e) {
fail("Construction with correct pointer failed!");
}
- @Test
public void testTraceOpenClose() {
JniTrace testTrace = prepareTraceToTest(); // This trace should be valid
}
}
- @Test
public void testGetSet() {
JniTrace testTrace = prepareTraceToTest();
}
- @Test
public void testPrintAndToString() {
JniTrace testTrace = prepareTraceToTest();
assertNotSame("toString returned empty data","",testTrace.toString() );
}
- @Test
public void testRequestFunctions() {
JniTrace testTrace = prepareTraceToTest();
assertSame("requestEventByName returned content on non existent name",null,testTrace.requestEventByName(wrongTracefileName) );
}
- @Test
public void testEventDisplacement() {
JniEvent testEvent = null;
assertEquals("seekToTime(time) timestamp after seek back is incoherent",firstEventTimestamp,testEvent.getEventTime().getTime());
}
- @Test
public void testEventDisplacementByTracefile() {
JniEvent testEvent = null;
package org.eclipse.linuxtools.lttng.jni;
-import static org.junit.Assert.*;
-import org.junit.Test;
+import junit.framework.TestCase;
/*
Functions tested here :
public void printTracefileInformation()
*/
-public class JniTracefileTest
+public class JniTracefileTest extends TestCase
{
+ private final static boolean printLttDebug = false;
+
private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
private final static String tracefileName1="kernel0";
// This trace should be valid
try {
- tmpTracefile = new JniTrace(tracepath1).requestTracefileByName(tracefileName1);
+ tmpTracefile = new JniTrace(tracepath1, printLttDebug).requestTracefileByName(tracefileName1);
}
catch( JniException e) { }
}
- @Test
public void testTracefileConstructors() {
JniTrace testTrace = null;
JniTracefile testTracefile1 = null;
// This trace should be valid and will be used in test
try {
- testTrace = new JniTrace(tracepath1);
+ testTrace = new JniTrace(tracepath1, printLttDebug);
}
catch( JniException e) { }
}
- @Test
public void testGetSet() {
JniTracefile testTracefile = prepareTracefileToTest();
}
- @Test
public void testPrintAndToString() {
JniTracefile testTracefile = prepareTracefileToTest();
}
- @Test
public void testEventDisplacement() {
int readValue = -1;
import org.eclipse.linuxtools.lttng.TraceDebug;
import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
import org.eclipse.linuxtools.tmf.trace.TmfExperiment;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import junit.framework.TestCase;
/**
* @author alvaro
*
*/
-public class TestStateManager {
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- ActivateDebugging.activate();
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
+public class TestStateManager extends TestCase {
+
public void testSetTraceSelection() {
String logName = "traceset/trace1";
String expectedFieldName = expectedField.getInName();
for (int i = 0; i < fields.length; i++) {
field = (LttngEventField) fields[i];
- fieldname = field.getName();
+ fieldname = field.getId();
if (fieldname.equals(expectedFieldName)) {
Object fieldObj = field.getValue();
if (fieldObj instanceof Long) {
String expectedFieldName = expectedField.getInName();
for (int i = 0; i < fields.length; i++) {
field = (LttngEventField) fields[i];
- fieldname = field.getName();
+ fieldname = field.getId();
if (fieldname.equals(expectedFieldName)) {
Object fieldObj = field.getValue();
if (fieldObj instanceof String) {
sb.append(" number of fields: " + fields.length + "Fields: ");
for (int i = 0; i < fields.length; i++) {
field = (LttngEventField) fields[i];
- sb.append(field.getName() + " ");
+ sb.append(field.getId() + " ");
}
TraceDebug.debug(sb.toString(), 5);
+ ExecutionMode.LTTV_STATE_SYSCALL.getInName());
}
- if (stackState.getEntry_LttTime() != trcEvent.getTimestamp()) {
+ if (stackState.getEntry_LttTime() != trcEvent.getTimestamp().getValue()) {
TraceDebug.debug("Unexpected Entry time: "
+ trcEvent.getTimestamp() + " Expected: "
+ stackState.getEntry_LttTime());
exState = new LttngExecutionState();
exState.setExec_mode(ExecutionMode.LTTV_STATE_SYSCALL);
exState.setExec_submode(submode);
- exState.setEntry_Time(trcEvent.getTimestamp());
- exState.setChange_Time(trcEvent.getTimestamp());
+ exState.setEntry_Time(trcEvent.getTimestamp().getValue());
+ exState.setChange_Time(trcEvent.getTimestamp().getValue());
exState.setCum_cpu_time(0L);
return false;
package org.eclipse.linuxtools.lttng.trace;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
import org.eclipse.linuxtools.tmf.event.TmfEvent;
import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
-import org.junit.Test;
+import junit.framework.TestCase;
/*
Functions tested here :
*/
-public class LTTngTraceTest {
+public class LTTngTraceTest extends TestCase {
private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu";
private final static String wrongTracePath="/somewhere/that/does/not/exist";
return tmpStream;
}
-
- @Test
+
public void testTraceConstructors() {
@SuppressWarnings("unused")
LTTngTrace testStream1 = null;
}
}
- @Test
public void testParseNextEvent() {
TmfEvent tmpEvent = null;
LTTngTrace testStream1 = prepareStreamToTest();
assertEquals("tmpEvent has wrong timestamp after second parseEvent()",secondEventTimestamp,(long)tmpEvent.getTimestamp().getValue() );
}
- @Test
public void testSeekLocation() {
TmfEvent tmpEvent = null;
TmfTraceContext tmpContext = new TmfTraceContext(null, null, 0);
assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterSeekTest1,(long)((TmfTimestamp)tmpContext.getLocation()).getValue() );
tmpEvent = testStream1.parseEvent(tmpContext);
assertNotSame("tmpEvent is null after first seekLocation()",null,tmpEvent );
- assertTrue("tmpEvent has wrong reference after first seekLocation()", ((String)tmpEvent.getReference().getValue()).contains(seek1EventReference) );
+ assertTrue("tmpEvent has wrong reference after first seekLocation()", ((String)tmpEvent.getReference().getReference()).contains(seek1EventReference) );
// Seek to the last timestamp
tmpContext = testStream1.seekLocation(new TmfTimestamp(timestampToSeekLast));
assertEquals("tmpContext has wrong timestamp after seekLocation() to last",contextValueAfterSeekLast,(long)((TmfTimestamp)tmpContext.getLocation()).getValue() );
tmpEvent = testStream1.parseEvent(tmpContext);
assertNotSame("tmpEvent is null after seekLocation() to last ",null,tmpEvent );
- assertTrue("tmpEvent has wrong reference after seekLocation() to last",((String)tmpEvent.getReference().getValue()).contains(seekLastEventReference) );
+ assertTrue("tmpEvent has wrong reference after seekLocation() to last",((String)tmpEvent.getReference().getReference()).contains(seekLastEventReference) );
// Seek to the first timestamp (startTime)
tmpContext = testStream1.seekLocation(new TmfTimestamp(firstEventTimestamp));
assertEquals("tmpContext has wrong timestamp after seekLocation() to start",contextValueAfterFirstEvent,(long)((TmfTimestamp)tmpContext.getLocation()).getValue() );
tmpEvent = testStream1.parseEvent(tmpContext);
assertNotSame("tmpEvent is null after seekLocation() to start ",null,tmpEvent );
- assertTrue("tmpEvent has wrong reference after seekLocation() to start",((String)tmpEvent.getReference().getValue()).contains(firstEventReference) );
+ assertTrue("tmpEvent has wrong reference after seekLocation() to start",((String)tmpEvent.getReference().getReference()).contains(firstEventReference) );
}
- @Test
public void testGetter() {
TmfEvent tmpEvent = null;
LTTngTrace testStream1 = prepareStreamToTest();
// Test current event
assertNotSame("tmpEvent is null after first event",null,tmpEvent );
- assertTrue("tmpEvent has wrong reference after first event",((String)tmpEvent.getReference().getValue()).contains(firstEventReference) );
+ assertTrue("tmpEvent has wrong reference after first event",((String)tmpEvent.getReference().getReference()).contains(firstEventReference) );
}
- @Test
public void testToString() {
LTTngTrace testStream1 = prepareStreamToTest();
protected String groupName = "";
protected String className = "";
protected CompositeType contType = CompositeType.UNKNOWN;
- protected long next_good_time = -1;
+ protected Long next_good_time = -1L;
/*Time of first event which trigger the creation of this local resource */
- protected long insertionTime = -1;
+ protected Long insertionTime = -1L;
// ========================================================================
// Constructors
import java.util.Vector;
+import org.eclipse.linuxtools.lttng.TraceDebug;
import org.eclipse.linuxtools.lttng.state.StateStrings.ProcessStatus;
import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing;
import org.eclipse.linuxtools.lttng.state.model.LttngProcessState;
procContainer.getUniqueId(), stateProcess.getName(),
traceStartTime, traceEndTime, "", stateProcess.getType()
.getInName(), stateProcess.getCpu(), stateProcess
- .getInsertion_time().getValue());
- localProcess.setCreationTime(stateProcess.getCreation_time().getValue());
+ .getInsertion_time());
+
+
+ localProcess.setCreationTime(stateProcess.getCreation_time());
localProcess.setPid(stateProcess.getPid());
localProcess.setTgid(stateProcess.getTgid());
localProcess.setPpid(stateProcess.getPpid());
}
//hashed_process_data = processlist_get_process_data(process_list,pid_out,process->cpu,&birth,trace_num);
- TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCpu(), traceSt.getTraceId(),process_in.getCreation_time().getValue() );
+ TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCpu(), traceSt.getTraceId(),process_in.getCreation_time() );
if ( localProcess == null ) {
if ( (pid_in == 0) || (pid_in != process_in.getPpid()) ) {
LttngProcessState process_child = lttv_state_find_process(traceSt, trcEvent.getCpuId(), child_pid );
if ( process_child != null ) {
- TimeRangeEventProcess localProcess = procContainer.findProcess(process_child.getPid(), process_child.getCpu(), traceSt.getTraceId(), process_child.getCreation_time().getValue() );
+ TimeRangeEventProcess localProcess = procContainer.findProcess(process_child.getPid(), process_child.getCpu(), traceSt.getTraceId(), process_child.getCreation_time() );
if ( localProcess == null ) {
if ( (child_pid == 0) || (child_pid != process_child.getPpid()) ) {
// if(likely(process_list->current_hash_data[trace_num][cpu] != NULL) ){
// hashed_process_data = process_list->current_hash_data[trace_num][cpu];
// }
- TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(), process.getCreation_time().getValue());
+ TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(), process.getCreation_time());
if ( localProcess == null ) {
if ( (process.getPid() == 0) || (process.getPid() != process.getPpid()) ) {
if ( process != null ) {
- TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(), process.getCreation_time().getValue());
+ TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(), process.getCreation_time());
if ( localProcess == null ) {
if ( (process.getPid() == 0) || (process.getPid() != process.getPpid()) ) {
// if(likely(process_list->current_hash_data[trace_num][cpu] != NULL) ){
// hashed_process_data = process_list->current_hash_data[trace_num][cpu];
// }
- TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(), process.getCreation_time().getValue());
+ TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(), process.getCreation_time());
if ( localProcess == null ) {
if ( (process.getPid() == 0) || (process.getPid() != process.getPpid()) ) {
LttngProcessState process_in = lttv_state_find_process(traceSt, trcEvent.getCpuId(), pid_in );
if ( process_in != null ) {
- TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCpu(), traceSt.getTraceId(), process_in.getCreation_time().getValue());
+ TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCpu(), traceSt.getTraceId(), process_in.getCreation_time());
if (localProcess == null) {
if ( (process_in.getPid() == 0) || (process_in.getPid() != process_in.getPpid()) ) {
// may change
TimeRangeEventProcess localProcess = procContainer
.findProcess(stateProcess.getPid(), stateProcess.getCpu(), traceId, stateProcess
- .getCreation_time().getValue());
+ .getCreation_time());
// Add process to process list if not present
if (localProcess == null) {
// processlist_get_process_data(process_list,pid_out,process->cpu,&birth,trace_num);
TimeRangeEventProcess localProcess = procContainer
.findProcess(process.getPid(), process.getCpu(), traceSt
- .getTraceId(), process.getCreation_time().getValue());
+ .getTraceId(), process.getCreation_time());
// Add process to process list if not present
// Replace C Call :
// tfs->cpu, &birth, trace_num);
TimeRangeEventProcess localProcess = procContainer
.findProcess(process.getPid(), process.getCpu(), traceSt
- .getTraceId(), process.getCreation_time().getValue());
+ .getTraceId(), process.getCreation_time());
// Add process to process list if not present
// Replace C Call :
// process->cpu, &birth,trace_num);
TimeRangeEventProcess localProcess = procContainer
.findProcess(process.getPid(), process.getCpu(), traceSt
- .getTraceId(), process.getCreation_time().getValue());
+ .getTraceId(), process.getCreation_time());
// Add process to process list if not present
// Replace C Call :
TimeRangeEventProcess localProcess = procContainer
.findProcess(process.getPid(), process.getCpu(), traceSt
.getTraceId(), process
- .getCreation_time().getValue());
+ .getCreation_time());
// This is as it was in the C ... ?
if (localProcess == null) {
TimeRangeEventProcess localProcess = procContainer
.findProcess(process.getPid(), process.getCpu(), traceSt
.getTraceId(), process
- .getCreation_time().getValue());
+ .getCreation_time());
// Add process to process list if not present
if (localProcess == null) {
* @return TimeRangeEventProcess[]
*/
public TimeRangeEventProcess[] readProcesses() {
+
// This allow us to return an Array of the correct type of the exact correct dimension, without looping
return allProcesses.values().toArray(new TimeRangeEventProcess[allProcesses.size()]);
}
* @return TimeRangeEventProcess
*/
public TimeRangeEventProcess findProcess(Long searchedPid, Long searchedCpuId, String searchedTraceID, Long searchedCreationtime) {
- // Get the TimeRangeEventProcess associated to a key we create here
+ // Get the TimeRangeEventProcess associated to a key we create here
TimeRangeEventProcess foundProcess = allProcesses.get( new ProcessKey(searchedPid, searchedCpuId, searchedTraceID, searchedCreationtime) );
-
+
return foundProcess;
}
}
return (valueRef.getPid().toString() + ":" + valueRef.getCpu().toString() + ":" + valueRef.getTraceID().toString() + ":" + valueRef.getCreationTime().toString());
}
- return (pid + ":" + cpuId + ":" + traceId + ":" + creationtime);
+ return (pid.toString() + ":" + cpuId.toString() + ":" + traceId.toString() + ":" + creationtime.toString());
}
}
package org.eclipse.linuxtools.lttng.ui.views.events;
+import org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.event.LttngEventContent;
import org.eclipse.linuxtools.tmf.event.TmfEvent;
import org.eclipse.linuxtools.tmf.ui.views.TmfEventsView;
import org.eclipse.swt.SWT;
@Override
protected String[] extractItemFields(TmfEvent event) {
String[] fields = new String[0];
+
if (event != null) {
fields = new String[] {
event.getTimestamp().toString(),
event.getSource().toString(),
event.getType().toString(),
event.getReference().toString(),
- event.getContent().getContent() };
+ ((LttngEventContent)event.getContent()).toString()
+ };
}
return fields;
}
*
*/
public class ResourcesTRangeUpdateFactory extends AbsEventProcessorFactory {
- // ========================================================================
- // Data
- // =======================================================================
- private final Map<String, IEventProcessing> eventNametoBeforeProcessor = new HashMap<String, IEventProcessing>();
- private final Map<String, IEventProcessing> eventNametoAfterProcessor = new HashMap<String, IEventProcessing>();
+ // ========================================================================
+ // Data
+ // =======================================================================
+ private final Map<String, IEventProcessing> eventNametoBeforeProcessor = new HashMap<String, IEventProcessing>();
+ private final Map<String, IEventProcessing> eventNametoAfterProcessor = new HashMap<String, IEventProcessing>();
private ResourcesTRangeFinishUpdateHandler finishProcessor = null;
- private static ResourcesTRangeUpdateFactory instance = null;
- private ResourcesTRangeBeforeUpdateHandlers instantiateBeforeHandler = new ResourcesTRangeBeforeUpdateHandlers();
- private ResourcesTRangeAfterUpdateHandlers instantiateAfterHandler = new ResourcesTRangeAfterUpdateHandlers();
-
-
+ private static ResourcesTRangeUpdateFactory instance = null;
+ private ResourcesTRangeBeforeUpdateHandlers instantiateBeforeHandler = new ResourcesTRangeBeforeUpdateHandlers();
+ private ResourcesTRangeAfterUpdateHandlers instantiateAfterHandler = new ResourcesTRangeAfterUpdateHandlers();
+
private ResourcesTRangeUpdateFactory() {
- // Create one instance of each individual event handler and add the instance to the map
+ // Create one instance of each individual event handler and add the
+ // instance to the map
- // *** BEFORE HOOKS ***
+ // *** BEFORE HOOKS ***
eventNametoBeforeProcessor.put(
StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE.getInName(),
instantiateBeforeHandler.getBeforeSchedChangeHandler());
-
- eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_ENTRY
+
+ eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_ENTRY
.getInName(), instantiateBeforeHandler
.getBeforeExecutionModeTrap());
eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_EXIT
.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT
.getInName(), instantiateBeforeHandler
.getBeforeExecutionModeTrap());
-
- eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_ENTRY
+
+ eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_ENTRY
.getInName(), instantiateBeforeHandler
.getBeforeExecutionModeIrq());
eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_EXIT
.getInName(), instantiateBeforeHandler
.getBeforeExecutionModeIrq());
-
- eventNametoBeforeProcessor.put(
+
+ eventNametoBeforeProcessor.put(
StateStrings.Events.LTT_EVENT_SOFT_IRQ_RAISE.getInName(),
instantiateBeforeHandler.getBeforeExecutionModeSoftIrq());
eventNametoBeforeProcessor.put(
eventNametoBeforeProcessor.put(
StateStrings.Events.LTT_EVENT_SOFT_IRQ_EXIT.getInName(),
instantiateBeforeHandler.getBeforeExecutionModeSoftIrq());
-
- eventNametoBeforeProcessor.put(
+
+ eventNametoBeforeProcessor.put(
StateStrings.Events.LTT_EVENT_REQUEST_ISSUE.getInName(),
instantiateBeforeHandler.getBeforeBdevEvent());
eventNametoBeforeProcessor.put(
StateStrings.Events.LTT_EVENT_REQUEST_COMPLETE.getInName(),
instantiateBeforeHandler.getBeforeBdevEvent());
-
-
-
- // *** AFTER HOOKS ***
+
+ // *** AFTER HOOKS ***
eventNametoAfterProcessor.put(
StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE.getInName(),
instantiateAfterHandler.getAfterSchedChangeHandler());
finishProcessor = new ResourcesTRangeFinishUpdateHandler();
- }
-
-
- /**
+ }
+
+ /**
*
*/
public static AbsEventProcessorFactory getInstance() {
- if (instance == null) {
+ if (instance == null) {
instance = new ResourcesTRangeUpdateFactory();
- }
- return instance;
- }
-
- @Override
- public IEventProcessing getAfterProcessor(String eventType) {
- return eventNametoAfterProcessor.get(eventType);
- }
+ }
+ return instance;
+ }
+
+ @Override
+ public IEventProcessing getAfterProcessor(String eventType) {
+ return eventNametoAfterProcessor.get(eventType);
+ }
- @Override
- public IEventProcessing getBeforeProcessor(String eventType) {
- return eventNametoBeforeProcessor.get(eventType);
- }
+ @Override
+ public IEventProcessing getBeforeProcessor(String eventType) {
+ return eventNametoBeforeProcessor.get(eventType);
+ }
@Override
public IEventProcessing getfinishProcessor() {
else {
if ( ( ((ResourceKey)obj).getResourceId().equals(this.resourceId)) &&
( ((ResourceKey)obj).getTraceId().equals(this.traceId)) &&
- ( ((ResourceKey)obj).getType().equals(this.traceId)) )
+ ( ((ResourceKey)obj).getType().equals(this.type)) )
{
isSame = true;
}
if (process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) &&
!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
node.getValue().cpuTime += event.getTimestamp().getValue()
- - process.getState().getChange_LttTime().getValue();
+ - process.getState().getChange_LttTime();
}
}
if (!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
node.getValue().elapsedTime += event.getTimestamp().getValue()
- - process.getState().getEntry_LttTime().getValue();
+ - process.getState().getEntry_LttTime();
}
}
if (!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
long cumulativeCpuTime = process.getState().getCum_cpu_time();
- long delta = event.getTimestamp().getValue() - process.getState().getEntry_LttTime().getValue();
+ long delta = event.getTimestamp().getValue() - process.getState().getEntry_LttTime();
process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
node.getValue().cumulativeCpuTime += process.getState().getCum_cpu_time();
}
else if (process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) &&
!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
long cumulativeCpuTime = process.getState().getCum_cpu_time();
- long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime().getValue();
+ long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime();
process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
node.getValue().cumulativeCpuTime += process.getState().getCum_cpu_time();
}
if (process.getState().getProc_status().equals(ProcessStatus.LTTV_STATE_RUN) &&
!process.getState().getExec_mode().equals(ExecutionMode.LTTV_STATE_MODE_UNKNOWN)) {
long cumulativeCpuTime = process.getState().getCum_cpu_time();
- long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime().getValue();
+ long delta = event.getTimestamp().getValue() - process.getState().getChange_LttTime();
process.getState().setCum_cpu_time(cumulativeCpuTime + delta);
}
}
package org.eclipse.linuxtools.lttng.stubs;
-import java.io.EOFException;
import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.Vector;
import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfEventContent;
-import org.eclipse.linuxtools.tmf.event.TmfEventFormat;
-import org.eclipse.linuxtools.tmf.event.TmfEventReference;
-import org.eclipse.linuxtools.tmf.event.TmfEventSource;
-import org.eclipse.linuxtools.tmf.event.TmfEventType;
import org.eclipse.linuxtools.tmf.trace.ITmfEventParser;
import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
*/
public class LTTngEventParserStub implements ITmfEventParser {
- // ========================================================================
- // Attributes
- // ========================================================================
-
- private final int NB_FORMATS = 10;
- private final TmfEventFormat[] fFormats;
-
- // ========================================================================
- // Constructors
- // ========================================================================
-
- public LTTngEventParserStub() {
- fFormats = new TmfEventFormat[NB_FORMATS];
- for (int i = 0; i < NB_FORMATS; i++) {
- Vector<String> format = new Vector<String>();
- for (int j = 1; j <= i; j++) {
- format.add(new String("Fmt-" + i + "-Fld-" + j));
- }
- String[] fields = new String[i];
- fFormats[i] = new TmfEventFormat(format.toArray(fields));
- }
- }
-
- // ========================================================================
- // Accessors
- // ========================================================================
-
- // ========================================================================
- // Operators
- // ========================================================================
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventParser#parseNextEvent()
- */
- static final String typePrefix = "Type-";
- public TmfEvent parseNextEvent(ITmfTrace eventStream, TmfTraceContext context) throws IOException {
-
- if (! (eventStream instanceof LTTngTraceStub)) {
- return null;
- }
-
- // Highly inefficient...
- RandomAccessFile stream = ((LTTngTraceStub) eventStream).getStream();
- String name = eventStream.getName();
- name = name.substring(name.lastIndexOf('/') + 1);
-
- synchronized(stream) {
- long location = 0;
- if (context != null)
- location = (Long) (context.getLocation());
- stream.seek(location);
-
- try {
- // Read the individual fields
- long ts = stream.readLong();
- String source = stream.readUTF();
- String type = stream.readUTF();
- @SuppressWarnings("unused")
- int reference = stream.readInt();
-
- // Read the event parts
- int typeIndex = Integer.parseInt(type.substring(typePrefix.length()));
- String[] fields = new String[typeIndex];
- for (int i = 0; i < typeIndex; i++) {
- fields[i] = stream.readUTF();
- }
-
- // Format the content from the individual fields
- String content = "[";
- if (typeIndex > 0) {
- content += fields[0];
- }
- for (int i = 1; i < typeIndex; i++) {
- content += ", " + fields[i];
- }
- content += "]";
-
- // Update the context
- context.setLocation(stream.getFilePointer());
- context.incrIndex();
- try {
- long ts2 = stream.readLong();
- context.setTimestamp(new LTTngTimestampStub(ts2));
- } catch (EOFException e) {
- context.setTimestamp(null);
- }
-
- // Create the event
- TmfEvent event = new TmfEvent(
- new LTTngTimestampStub(ts),
- new TmfEventSource(source),
- new TmfEventType(type, fFormats[typeIndex]),
- new TmfEventContent(content, fFormats[typeIndex]),
- new TmfEventReference(name));
-
- return event;
-
- } catch (EOFException e) {
- context.setTimestamp(null);
- }
- }
- return null;
- }
+ public TmfEvent parseNextEvent(ITmfTrace stream, TmfTraceContext context)
+ throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+// // ========================================================================
+// // Attributes
+// // ========================================================================
+//
+// private final int NB_FORMATS = 10;
+// private final TmfEventFormat[] fFormats;
+//
+// // ========================================================================
+// // Constructors
+// // ========================================================================
+//
+// public LTTngEventParserStub() {
+// fFormats = new TmfEventFormat[NB_FORMATS];
+// for (int i = 0; i < NB_FORMATS; i++) {
+// Vector<String> format = new Vector<String>();
+// for (int j = 1; j <= i; j++) {
+// format.add(new String("Fmt-" + i + "-Fld-" + j));
+// }
+// String[] fields = new String[i];
+// fFormats[i] = new TmfEventFormat(format.toArray(fields));
+// }
+// }
+//
+// // ========================================================================
+// // Accessors
+// // ========================================================================
+//
+// // ========================================================================
+// // Operators
+// // ========================================================================
+//
+// /* (non-Javadoc)
+// * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventParser#parseNextEvent()
+// */
+// static final String typePrefix = "Type-";
+// public TmfEvent parseNextEvent(ITmfTrace eventStream, TmfTraceContext context) throws IOException {
+//
+// if (! (eventStream instanceof LTTngTraceStub)) {
+// return null;
+// }
+//
+// // Highly inefficient...
+// RandomAccessFile stream = ((LTTngTraceStub) eventStream).getStream();
+// String name = eventStream.getName();
+// name = name.substring(name.lastIndexOf('/') + 1);
+//
+// synchronized(stream) {
+// long location = 0;
+// if (context != null)
+// location = (Long) (context.getLocation());
+// stream.seek(location);
+//
+// try {
+// // Read the individual fields
+// long ts = stream.readLong();
+// String source = stream.readUTF();
+// String type = stream.readUTF();
+// @SuppressWarnings("unused")
+// int reference = stream.readInt();
+//
+// // Read the event parts
+// int typeIndex = Integer.parseInt(type.substring(typePrefix.length()));
+// String[] fields = new String[typeIndex];
+// for (int i = 0; i < typeIndex; i++) {
+// fields[i] = stream.readUTF();
+// }
+//
+// // Format the content from the individual fields
+// String content = "[";
+// if (typeIndex > 0) {
+// content += fields[0];
+// }
+// for (int i = 1; i < typeIndex; i++) {
+// content += ", " + fields[i];
+// }
+// content += "]";
+//
+// // Update the context
+// context.setLocation(stream.getFilePointer());
+// context.incrIndex();
+// try {
+// long ts2 = stream.readLong();
+// context.setTimestamp(new LTTngTimestampStub(ts2));
+// } catch (EOFException e) {
+// context.setTimestamp(null);
+// }
+//
+// // Create the event
+// TmfEvent event = new TmfEvent(
+// new LTTngTimestampStub(ts),
+// new TmfEventSource(source),
+// new TmfEventType(type, fFormats[typeIndex]),
+// new TmfEventContent(content, fFormats[typeIndex]),
+// new TmfEventReference(name));
+//
+// return event;
+//
+// } catch (EOFException e) {
+// context.setTimestamp(null);
+// }
+// }
+// return null;
+// }
}
import org.eclipse.linuxtools.tmf.event.TmfEvent;
import org.eclipse.linuxtools.tmf.event.TmfEventSource;
import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
-import org.eclipse.linuxtools.lttng.jni.JniEvent;
import org.eclipse.linuxtools.lttng.LttngException;
+import org.eclipse.linuxtools.lttng.jni.JniEvent;
/**
* <b><u>LttngEvent</u></b><p>
@SuppressWarnings("unused")
public class LttngEvent extends TmfEvent {
- // Reference to the JNI JniEvent. Should only used INTERNALLY
+ // Reference to the JNI JniEvent. Should only be used INTERNALLY
private JniEvent jniEventReference = null;
-
+
/**
* Constructor with parameters.<p>
*
* @see org.eclipse.linuxtools.lttng.event.LttngEventType
* @see org.eclipse.linuxtools.lttng.event.LttngEventContent
* @see org.eclipse.linuxtools.lttng.event.LttngEventReference
- * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+ * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
*/
- public LttngEvent(LttngTimestamp timestamp, TmfEventSource source, LttngEventType type, LttngEventContent content, LttngEventReference reference, JniEvent lttEvent) throws LttngException {
- super(timestamp, source, type, content, reference);
-
- // Sanity checks
- if ( (timestamp == null) || (source == null) || (type == null) || (content == null) || (reference == null) || (lttEvent == null) ) {
- throw new LttngException("Event creation with null values is forbidden!");
- }
+ public LttngEvent(LttngTimestamp timestamp, TmfEventSource source, LttngEventType type, LttngEventContent content, LttngEventReference reference, JniEvent lttEvent) {
+ super(timestamp, source, type, reference);
+ fContent = content;
jniEventReference = lttEvent;
}
* @param oldEvent Event we want to copy from.
*
*/
- public LttngEvent(LttngEvent oldEvent) throws LttngException {
+ public LttngEvent(LttngEvent oldEvent) {
this( (LttngTimestamp)oldEvent.getTimestamp(),
(TmfEventSource)oldEvent.getSource(),
(LttngEventType)oldEvent.getType(),
/**
* Return the channel name of this event.<p>
*
- * @return The name of the channel for this event
+ * @return Channel (tracefile) for this event
*/
public String getChannelName() {
- String returnedValue = "";
+ String returnedChannel = "";
- // This should always be true
- if ( this.getType() instanceof LttngEventType ) {
- returnedValue = ( (LttngEventType)this.getType() ).getChannelName();
- }
- return returnedValue;
+ return ( (LttngEventType)this.getType() ).getTracefileName();
}
/**
* Cpu id number of this event.<p>
*
- * @return The cpu id
+ * @return Cpu id
*/
public long getCpuId() {
- long returnedValue =-1;
-
- // This should always be true
- if ( this.getType() instanceof LttngEventType ) {
- returnedValue = ( (LttngEventType)this.getType() ).getCpuId();
- }
- return returnedValue;
+ return ( (LttngEventType)this.getType() ).getCpuId();
}
/**
* Marker name of this event.<p>
*
- * @return The marker name
+ * @return Marker name
*/
public String getMarkerName() {
String returnedValue = "";
- // This should always be true
- if ( this.getType() instanceof LttngEventType ) {
- returnedValue = ( (LttngEventType)this.getType() ).getMarkerName();
- }
- return returnedValue;
+ return ( (LttngEventType)this.getType() ).getMarkerName();
}
+
+ public JniEvent getJniEventReference() {
+ return jniEventReference;
+ }
+
+ public void setJniEventReference(JniEvent newJniEventReference) {
+ this.jniEventReference = newJniEventReference;
+ }
+
+ @Override
+ public LttngEventContent getContent() {
+ return (LttngEventContent)fContent;
+ }
+
+ public void setContent(LttngEventContent newContent) {
+ fContent = newContent;
+ }
+
+ @Override
+ public LttngEventType getType() {
+ return (LttngEventType)fType;
+ }
+
+ public void setType(LttngEventType newType) {
+ fType = newType;
+ }
+
+
/**
* Convert this event into a Jni JniEvent.<p>
*
*
* @return The converted JniEvent
*
- * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+ * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
*/
public JniEvent convertEventTmfToJni() {
JniEvent tmpEvent = null;
+ // ***TODO***
+ // Should we remove the check to save some time??
+
// We don't want to send away events that are outdated as their informations could be invalid
// If the timestamp between the event and the trace are not coherent we will not perform the conversion
if ( jniEventReference.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime() == getTimestamp().getValue() ) {
tmpEvent = jniEventReference;
}
+ else {
+ System.out.println("WRONG TIMESTAMP : " + getTimestamp().getValue() + " vs " + jniEventReference.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime());
+ }
return tmpEvent;
}
package org.eclipse.linuxtools.lttng.event;
+import java.util.HashMap;
+
import org.eclipse.linuxtools.tmf.event.TmfEventContent;
-import org.eclipse.linuxtools.tmf.event.TmfEventField;
/**
* <b><u>LttngEventContent</u></b><p>
*/
public class LttngEventContent extends TmfEventContent {
+ // Hash map that contain the (parsed) fields. This is the actual payload of the event.
+ HashMap<String, LttngEventField> fFieldsMap = new HashMap<String, LttngEventField>();
+
/**
- * Constructor with parameters.<p>
+ * Default constructor.<p>
*
- * Content will be empty as no parsed content is given.
*
- * @param thisFormat The LttngEventFormat relative to the JniEvent
*/
- public LttngEventContent(LttngEventFormat thisFormat) {
- super("", thisFormat);
+ public LttngEventContent() {
+ super(null, null);
}
-
+
/**
* Constructor with parameters.<p>
*
- * @param thisFormat The LttngEventFormat relative to this JniEvent
- * @param thisParsedContent The string content of the JniEvent, already parsed
+ * @param thisParent Parent event for this content.
+ *
+ * @see org.eclipse.linuxtools.lttng.event.LttngEvent
+ */
+ public LttngEventContent(LttngEvent thisParent) {
+ super(thisParent, null);
+ }
+
+ /**
+ * Constructor with parameters, with optional content.<p>
+ *
+ * @param thisParent Parent event for this content.
+ * @param thisContent Already parsed content.
+ *
+ * @see org.eclipse.linuxtools.lttng.event.LttngEvent
*/
- public LttngEventContent(LttngEventFormat thisFormat, String thisParsedContent, TmfEventField[] thisFields) {
- super(thisParsedContent, thisFormat);
+ public LttngEventContent(LttngEvent thisParent, HashMap<String, LttngEventField> thisContent) {
+ super(thisParent, null);
- setFields(thisFields);
+ fFieldsMap = thisContent;
}
/**
* @param oldContent Content to copy from
*/
public LttngEventContent(LttngEventContent oldContent) {
- this( (LttngEventFormat)oldContent.getFormat(), oldContent.getContent(), oldContent.getFields() );
+ this((LttngEvent)oldContent.getEvent(), oldContent.getRawContent() );
+ }
+
+
+ public LttngEvent getEvent() {
+ return (LttngEvent)fParentEvent;
+ }
+
+ public void setEvent(LttngEvent newParent) {
+ fParentEvent = newParent;
+ }
+
+
+ // *** VERIFY ***
+ // These are not very useful, are they?
+ public LttngEventType getType() {
+ return (LttngEventType)fParentEvent.getType();
+// return (LttngEventType)fEventType;
+ }
+ public void setType(LttngEventType newType) {
+ ((LttngEvent)fParentEvent).setType(newType);
+// fEventType = newType;
}
+
+ // ***TODO***
+ // Find a better way to ensure content is sane!!
+ public void emptyContent() {
+ fFieldsMap.clear();
+ }
+
+ // ***VERIFY***
+ // A bit weird to return the _currently_parsed fields (unlike all like getFields() )
+ // Should we keep this?
/**
- * <b>*DEPRECATED*</b><br>Get all fields of the content.<p>
- *
- * <b><u>DO NOT USE!</b></u> <br>
- * This function will disapears soon! Use getFields(LttngEvent) instead.<p>
+ * Return currently parsed fields in an object array format.<p>
*
- * If the content was not parsed, format.parse() will get called.<p>
- *
- * @return An array of TmfEventFields
+ * @return Currently parsed fields.
*/
@Override
- public TmfEventField[] getFields() {
-
- // Request the field variable from the inherited class
- TmfEventField[] fields = super.getFields();
+ public Object[] getContent() {
+ Object[] returnedContent = fFieldsMap.values().toArray( new Object[fFieldsMap.size()] );
- // Field may be null if the content hasn't been parse yet
- // If that's the case, call the parsing function
- if (fields == null) {
- fields = ((LttngEventFormat) this.getFormat()).parse(this.getContent());
- setFields(fields);
- }
- return fields;
+ return returnedContent;
}
-
+
/**
- * <b>*DEPRECATED*</b><br>Get a single field of the content, from its id (position).<p>
+ * Return currently parsed fields in the internal hashmap format.<p>
*
- * <b><u>DO NOT USE!</b></u> <br>
- * This function will disapears soon! Use getFields(LttngEvent) instead.<p>
+ * @return Currently parsed fields.
+ */
+ public HashMap<String, LttngEventField> getRawContent() {
+ return fFieldsMap;
+ }
+
+// @SuppressWarnings("unchecked")
+// @Override
+// public LttngEventField[] getFields() {
+// LttngEventField tmpField = null;
+//
+// // *** TODO ***
+// // SLOW! SLOW! SLOW! We should prevent the user to use this!!
+// HashMap<String, Object> parsedContent = parseContent();
+//
+// String contentKey = null;
+// Iterator<String> contentItr = parsedContent.keySet().iterator();
+// while ( contentItr.hasNext() ) {
+// contentKey = contentItr.next();
+//
+// tmpField = new LttngEventField(this, contentKey, parsedContent.get(contentKey));
+// ((HashMap<String, LttngEventField>)fFields).put(contentKey, tmpField);
+// }
+//
+// return fFields.values().toArray(new LttngEventField[fFields.size()]);
+// }
+
+ /**
+ * Parse all fields and return them as an array of LttngFields.<p>
*
- * If the content was not parsed, format.parse() will get called.<p>
+ * Note : This function is heavy and should only be called if all fields are really needed.
*
- * @param id The id of the field we want to obtain.
+ * @return All fields.
*
- * @return A single LttngEventField
+ * @see @see org.eclipse.linuxtools.lttng.event.LttngEventField
*/
@Override
- public LttngEventField getField(int id) {
- LttngEventField returnedField = null;
+ public LttngEventField[] getFields() {
+ LttngEventField tmpField = null;
- if ( (id >= 0) && (id < this.getNbFields()) )
- {
- // Call getFields() of this object. Will parse if fields were'nt parse before.
- TmfEventField[] allFields = this.getFields();
+ LttngEventType tmpType = (LttngEventType)fParentEvent.getType();
+
+ for ( int pos=0; pos<tmpType.getNbFields(); pos++ ) {
+ String name = tmpType.getLabel(pos);
+ Object newValue = ((LttngEvent)getEvent()).convertEventTmfToJni().parseFieldByName(name);
- if ( allFields != null ) {
- returnedField = (LttngEventField)allFields[id];
- }
+ tmpField = new LttngEventField(this, name, newValue );
+ fFieldsMap.put(name, tmpField);
}
- return returnedField;
+ return fFieldsMap.values().toArray(new LttngEventField[fFieldsMap.size()]);
}
/**
- * Get all fields of the content.<p>
- *
- * If the content was not parsed, format.parse(LttngEvent) will get called.<p>
+ * Parse a single field from its given position.<p>
*
- * @param thisEvent The event to get the fields from
+ * @return The parsed field or null.
*
- * @return An array of TmfEventFields
+ * @see @see org.eclipse.linuxtools.lttng.event.LttngEventField
*/
- public TmfEventField[] getFields(LttngEvent thisEvent) {
-
- // Request the field variable from the inherited class
- TmfEventField[] fields = super.getFields();
+ @Override
+ public LttngEventField getField(int position) {
+ LttngEventField returnedField = null;
+ String label = fParentEvent.getType().getLabel(position);
- // Field may be null if the content hasn't been parse yet
- // If that's the case, call the parsing function
- if (fields == null) {
- fields = ((LttngEventFormat)this.getFormat()).parse(thisEvent);
- setFields(fields);
+ if ( label != null ) {
+ returnedField = this.getField(label);
}
- return fields;
+
+ return returnedField;
}
/**
- * Get a single field of the content, from its id (position).<p>
- *
- * If the content was not parsed, format.parse(LttngEvent) will get called.<p>
+ * Parse a single field from its given name.<p>
*
- * @param thisEvent The event to get the fields from
- * @param id The id of the field we want to obtain.
+ * @return The parsed field or null.
*
- * @return A single LttngEventField
+ * @see @see org.eclipse.linuxtools.lttng.event.LttngEventField
*/
- public LttngEventField getField(int id, LttngEvent thisEvent) {
- LttngEventField returnedField = null;
+ @Override
+ public LttngEventField getField(String name) {
+ // *** VERIFY ***
+ // Should we check if the field exists in LttngType before parsing?
+ // It could avoid calling parse for non-existent fields but would waste some cpu cycle on check?
+ LttngEventField returnedField = fFieldsMap.get(name);
- if ( (id >= 0) && (id < this.getNbFields()) ) {
- // Call getFields() of this object. Will parse if fields were'nt parse before.
- TmfEventField[] allFields = this.getFields(thisEvent);
+ if ( returnedField == null ) {
+ // *** VERIFY ***
+ // Should we really make sure we didn't get null before creating/inserting a field?
+ Object newValue = ((LttngEvent)getEvent()).convertEventTmfToJni().parseFieldByName(name);
- if ( allFields != null ) {
- returnedField = (LttngEventField)allFields[id];
+ if ( newValue!= null ) {
+ returnedField = new LttngEventField(this, name, newValue);
+ fFieldsMap.put(name, returnedField );
}
}
+
return returnedField;
}
-
+ // *** VERIFY ***
+ // *** Is this even useful?
+ @Override
+ protected void parseContent() {
+ fFields = getFields();
+ }
+
/**
- * toString() method.
+ * toString() method to print the content
*
- * @return Attributes of the object concatenated in String
+ * Note : this function parse all fields and so is very heavy to use.
*/
@Override
- public String toString() {
- return getContent().toString();
+ public String toString() {
+ String returnedString = "";
+
+ LttngEventField[] allFields = getFields();
+
+ for ( int pos=0; pos < allFields.length; pos++) {
+ returnedString += allFields[pos].toString() + " ";
+ }
+
+ return returnedString;
+
}
}
\ No newline at end of file
package org.eclipse.linuxtools.lttng.event;
+import org.eclipse.linuxtools.tmf.event.TmfEventContent;
import org.eclipse.linuxtools.tmf.event.TmfEventField;
/**
* mean the fields will have a name and a value.
*/
public class LttngEventField extends TmfEventField {
- private String fieldName = "";
+ /**
+ * Constructor with parameters.<p>
+ *
+ * @param parent Parent content for this field
+ * @param id Name (label) of this field
+ */
+ public LttngEventField(TmfEventContent parent, String id) {
+ super(parent, id, null);
+ }
+
/**
- * Constructor with parameters.<p>
+ * Constructor with parameters with optional value.<p>
*
- * @param name Name of the field
- * @param newContent ParsedContent we want to populate the field with.
- *
- * @see org.eclipse.linuxtools.lttng.jni.JniParser
+ * @param parent Parent content for this field
+ * @param id Name (label) of this field
+ * @param value Parsed value (payload) of this field
*/
- public LttngEventField(String name, Object newContent) {
- super(newContent);
-
- fieldName = name;
+ public LttngEventField(TmfEventContent parent, String id, Object value) {
+ super(parent, id, value);
}
/**
* @param oldField the field to copy from
*/
public LttngEventField(LttngEventField oldField) {
- this(oldField.fieldName, oldField.getValue());
+ this(oldField.getParent(), oldField.getId(), oldField.getValue());
}
-
- public String getName() {
- return fieldName;
- }
-
- /**
- * toString() method.<p>
- *
- * Print both field name and value (i.e. NAME:VALUE ).
- */
@Override
public String toString() {
- return fieldName + ":" + getValue().toString();
+ return getId().toString() + ":" + getValue().toString();
}
+
}
+++ /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:
- * William Bourque (wbourque@gmail.com) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.event;
-
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.linuxtools.tmf.event.TmfEventFormat;
-
-/**
- * <b><u>LttngEventFormat</u></b><p>
- *
- * Lttng specific implementation of the TmfEventFormat.<p>
- */
-public class LttngEventFormat extends TmfEventFormat {
-
- /**
- * Constructor with parameters.<p>
- *
- * @param labels The fields labels of the content.
- */
- public LttngEventFormat( String[] labels) {
- super(labels);
- }
-
- /**
- * Copy constructor.<p>
- *
- * @param oldFormat The format to copy from
- */
- public LttngEventFormat( LttngEventFormat oldFormat ) {
- this(oldFormat.getLabels());
- }
-
- /**
- * Parse the given LttngEvent.<p>
- *
- * @param thisEvent The LttngEvent to parse
- *
- * @return An array of LttngEventField that contain the parsed data
- */
- public LttngEventField[] parse(LttngEvent thisEvent) {
- // Obtain the parsed content from the JNI
- HashMap<String, Object> parsedMap = thisEvent.convertEventTmfToJni().parseAllFields();
- LttngEventField[] returnedField = new LttngEventField[parsedMap.size()];
-
- String fieldName = null;
- int position = 0;
- Iterator<String> iterator = parsedMap.keySet().iterator();
- // Loop to create the LttngEventField from the parsedContent
- while (iterator.hasNext()) {
- fieldName = iterator.next();
- returnedField[position] = new LttngEventField( fieldName, parsedMap.get(fieldName) );
- position++;
- }
-
- return returnedField;
- }
-
-
- /**
- * <b>*FIXME*</b><br>Parse from a HashMap of content.<p>
- *
- * This function will hopefully disapears soon!<br>
- * We need to parse WHILE CREATING LttngEvent, so we cannot always use parse(LttngEvent).<br>
- * This function is ugly but should be 100% safe to use.<p>
- *
- * @param parsedEvents HashMap of parsed content, as returned by JniParser.parseAllFields()
- *
- * @return An array of TmfEventFields
- */
- public LttngEventField[] parse(HashMap<String, Object> parsedEvents) {
- LttngEventField[] returnedField = new LttngEventField[parsedEvents.size()];
-
- String fieldName = null;
- int position = 0;
- Iterator<String> iterator = parsedEvents.keySet().iterator();
- // Loop to create the LttngEventField from the parsedContent in the map
- while (iterator.hasNext()) {
- fieldName = iterator.next();
- returnedField[position] = new LttngEventField( fieldName, parsedEvents.get(fieldName) );
- position++;
- }
- return returnedField;
- }
-
- /**
- * <b>*DEPRECATED*</b><br>Parse from the content string.<p>
- *
- * <b><u>DO NOT USE!</b></u> <br>
- * This function will disapears soon! Use parse(LttngEvent) instead.<br>
- * It is evil to parse content string directly as we <u>do not control the content</u>.<br>
- * So this would theorically works but it could break at any moment if kernel developpers changes their usual format.<p>
- *
- * This is provided because we need to implement this function since we inherit TmfFormat
- *
- * @param uselessContent Content to parse as String
- *
- * @return An array of TmfEventFields
- */
- public LttngEventField[] parse(String uselessContent) {
-
- // This function is _under commented_ because you should not use it
- // (this imply you shouldn't read it as well).
-
- // *** Begining of the evil "parse String" function
- //
- // - 1st : Find the number of ":" in the String. This will be the number of fields in the String.
- // Highly unreliable, as we depend on String content that we don't control!
- int nbFields = 0;
- for ( int pos = 0; pos < uselessContent.length(); pos++ ) {
- if ( uselessContent.substring(pos, pos+1).equals(":") ) {
- nbFields++;
- }
- }
-
- // - 2nd : Create the fields array
- LttngEventField[] tmpFields = new LttngEventField[nbFields];
-
- // - 3rd : Fill the array
- // Content is the NAME:VALUE format with space separators
- //
- // We search for 3 possible case :
- // - Field name
- // - Value (AKA payload or parsed content)
- // - "Out of range" (EOF found)
- //
- //
- int fieldPosition = 0;
- int lastFieldnamePos = 0;
- int lastDoubleDottedPos = 0;
- int lastSpacePos = 0;
- boolean isSearchingFieldname = true;
-
- String fieldName = "";
- String fieldValue = "";
-
- int pos = 0;
- while ( (pos < uselessContent.length()) && (fieldPosition<nbFields) )
- {
- // : symbol mean we found the end of "NAME"
- if ( uselessContent.substring(pos, pos+1).equals(":") ) {
-
- if ( isSearchingFieldname==false ) {
- fieldValue = uselessContent.substring(lastDoubleDottedPos+1, lastSpacePos);
- tmpFields[fieldPosition] = new LttngEventField( fieldName, fieldValue );
- fieldPosition++;
- isSearchingFieldname = true;
- }
-
- lastDoubleDottedPos = pos;
- }
- // space mean we found the end of VALUE
- else if ( uselessContent.substring(pos, pos+1).equals(" ") ) {
-
- if ( isSearchingFieldname==true ) {
- fieldName = uselessContent.substring(lastFieldnamePos, lastDoubleDottedPos);
- lastFieldnamePos = pos+1;
- isSearchingFieldname = false;
- }
-
- lastSpacePos = pos;
- }
- // pos+2 > length mean EOF
- else if ( pos+2 >= uselessContent.length() ) {
- fieldName = uselessContent.substring(lastSpacePos+1, lastDoubleDottedPos);
- fieldValue = uselessContent.substring(lastDoubleDottedPos+1, pos+1);
-
- tmpFields[fieldPosition] = new LttngEventField( fieldName, fieldValue );
- fieldPosition++;
- }
-
- pos++;
- }
-
- return tmpFields;
- }
-
-}
/**
* Constructor with parameters.<p>
*
+ * @param newTraceName Trace name
+ */
+ public LttngEventReference(String newTraceName) {
+ super("");
+ tracename = newTraceName;
+ }
+
+ /**
+ * Constructor with parameters with optional tracefile path.<p>
+ *
* @param newTracefilePath Complete tracefile path
- * @param newTraceName The Trace name
+ * @param newTraceName Trace name
*/
public LttngEventReference(String newTracefilePath, String newTraceName) {
super(newTracefilePath);
this.tracename = tracename;
}
+ public String getValue() {
+ return (String)fReference;
+ }
+
+ public void setValue(String newReference) {
+ fReference = newReference;
+ }
+
/**
* toString() method.<p>
*
- * We return only tracename, as it will be used directly in the eventsView and it gives a better output.
+ * We return only tracename, as it will be used directly in the eventsView.
+ * Returning only tracename gives a better output.
*
* @return tracename as String
*/
--- /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:
+ * William Bourque (wbourque@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.event;
+
+import org.eclipse.linuxtools.tmf.event.*;
+
+/**
+ * <b><u>LttngEventSource</u></b><p>
+ *
+ * Lttng specific implementation of the TmfEventSource
+ */
+public class LttngEventSource extends TmfEventSource {
+
+ /**
+ * Default Constructor.<p>
+ *
+ */
+ public LttngEventSource() {
+ super();
+ }
+
+ /**
+ * Copy Constructor.<p>
+ *
+ * @param newSource Source of the event as string.
+ */
+ public LttngEventSource(String newSource) {
+ super(newSource);
+ }
+
+
+ /**
+ * Copy Constructor.<p>
+ *
+ * @param oldSource LttngEventSource to copy from.
+ */
+ public LttngEventSource(LttngEventSource oldSource) {
+ this( (String)oldSource.getSourceId() );
+ }
+
+
+ public String getSourceId() {
+ return (String)fSourceId;
+ }
+
+ public void setSourceId(String newSource) {
+ fSourceId = newSource;
+ }
+
+ public String toString() {
+ return fSourceId.toString();
+ }
+}
* This implementation add some attributes to the basic Tmf object.
*/
public class LttngEventType extends TmfEventType {
- private String channelName = "";
- private long cpuId = 0;
- private String markerName = "";
+
+ private String tracefileName = null;
+ private Long cpuId = null;
+ private String markerName = null;
/**
- * Constructor with parameters.<p>
+ * Default Constructor.<p>
*
- * @param thisChannelName Channel name. It is the Tracefile name in LTT
- * @param thisCpuId CPU id number from LTT
- * @param thisMarkerName JniMarker name. It is the marker_info name in LTT
- * @param thisFormat The format relative to the event
+ */
+ public LttngEventType() {
+ super();
+ }
+
+ /**
+ * Constructor with parameters.<p>
*
- * @see org.eclipse.linuxtools.lttng.event.LttngEventFormat
+ * @param thisTracefileName Tracefile (channel) name in Ltt
+ * @param thisMarkerName Marker name in LTT
+ * @param thisMarkerfieldsName MarkerFields related to this marker
*/
- public LttngEventType(String thisChannelName, long thisCpuId, String thisMarkerName, LttngEventFormat thisFormat) {
- super( thisChannelName + "/" + thisCpuId + "/" + thisMarkerName, thisFormat);
+ public LttngEventType(String thisTracefileName, Long thisCpuId, String thisMarkerName, String[] thisMarkerfieldsName) {
+ super( thisTracefileName + "/" + thisCpuId + "/" + thisMarkerName, thisMarkerfieldsName);
- channelName = thisChannelName;
- cpuId = thisCpuId;
- markerName = thisMarkerName;
+ tracefileName = thisTracefileName;
+ cpuId = thisCpuId;
+ markerName = thisMarkerName;
}
/**
* Copy constructor.<p>
*
* @param oldType Type we want to copy from
- *
- * @see org.eclipse.linuxtools.lttng.event.LttngEventFormat
*/
public LttngEventType(LttngEventType oldType) {
- this(oldType.channelName, oldType.cpuId, oldType.markerName, (LttngEventFormat)oldType.getFormat());
+ this(oldType.tracefileName, oldType.cpuId, oldType.markerName, oldType.getLabels());
}
- public String getChannelName() {
- return channelName;
+ public String getTracefileName() {
+ return tracefileName;
}
-
- public long getCpuId() {
+ public Long getCpuId() {
return cpuId;
}
-
public String getMarkerName() {
return markerName;
}
-
/**
* toString() method.
*
- * @return TypeId (channel/cpu/marker) of the object
+ * @return TypeId (channel/marker) of the object
*/
@Override
public String toString() {
- return getTypeId();
+ // *** TODO ***
+ // This is used as-it in the events view, so we won't change its format.
+ // ...but maybe we should?
+ return tracefileName + "/" + cpuId.toString() + "/" + markerName;
}
}
// Required by Serializable
private static final long serialVersionUID = -7016853105162491273L;
-
+
+ /**
+ * Default Constructor.<p>
+ *
+ */
+ public LttngTimestamp() {
+ super(Long.MIN_VALUE, (byte) -9);
+ }
+
/**
* Constructor with parameters.<p>
*
- * @param newEventTime JniTime as long, unit expected to be nanoseconds
+ * @param newEventTime Time as long, unit expected to be nanoseconds
*/
public LttngTimestamp(long newEventTime) {
super(newEventTime, (byte) -9);
public LttngTimestamp(TmfTimestamp oldEventTime) {
this(oldEventTime.getValue());
}
-
+
+ @Override
+ public long getValue() {
+ return fValue;
+ }
+
+ public void setValue(long newValue) {
+ fValue = newValue;
+ }
+
/**
* Get the second part in timestamp.<p>
*
public String getNanoSeconds() {
return formatNs(fValue);
}
-
+
/*
* Use the exponent to format the second in the correct format.
*/
/**
* toString() method.
*
- * @return Attributes of this object.
+ * @return timestamp, as string
*/
@Override
public String toString() {
+package org.eclipse.linuxtools.lttng.jni;
/*******************************************************************************
* Copyright (c) 2009 Ericsson
*
* William Bourque (wbourque@gmail.com) - Initial API and implementation
*******************************************************************************/
-package org.eclipse.linuxtools.lttng.jni;
import java.util.HashMap;
// Note that all type have been scaled up as there is no "unsigned" in java
// This might be a problem about "unsigned long" as there is no equivalent
// in java
- private Jni_C_Pointer tracefilePtr = new Jni_C_Pointer();;
- private int eventMarkerId = 0;
+ private Jni_C_Pointer tracefilePtr = new Jni_C_Pointer();
private JniTime eventTime = null;
- private long eventDataSize = 0;
// These methods need a tracefile pointer, instead of a event pointer
private native int ltt_readNextEvent(long tracefilePtr);
@SuppressWarnings("unused")
private native long ltt_getTimestamp(long eventPtr);
private native int ltt_getEventMarkerId(long eventPtr);
+ private native long ltt_getNanosencondsTime(long eventPtr);
+ @SuppressWarnings("unused")
private native void ltt_feedEventTime(long eventPtr, JniTime eventTime);
private native long ltt_getEventDataSize(long eventPtr);
@SuppressWarnings("unused")
eventState = oldEvent.eventState;
tracefilePtr = oldEvent.tracefilePtr;
- eventMarkerId = oldEvent.eventMarkerId;
eventTime = oldEvent.eventTime;
- eventDataSize = oldEvent.eventDataSize;
}
/**
*
* @exception JniException
*
- * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
- * @see org.eclipse.linuxtools.lttng.jni.JniMarker
- * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniMarker
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
*/
public JniEvent(Jni_C_Pointer newEventPtr, HashMap<Integer, JniMarker> newMarkersMap, JniTracefile newParentTracefile) throws JniException {
// Try to move to the first event
// If the event is Out of Range (ERANGE) at the first read,
- // this event type will never been usable.
+ // this event type will never be usable.
// In that case, throw JniNoSuchEventException to warn the tracefile.
- //
- // Position ourself on the first event.
eventState = positionToFirstEvent();
if (eventState != EOK) {
throw new JniNoSuchEventException("Object not populated, unusable. There is probably no event of that type in the trace. (JniEvent)");
*
* @return LTT read status, as defined in Jni_C_Common.
*
- * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
*/
public int readNextEvent() {
// Ask Ltt to read the next event for this particular tracefile
- eventState = ltt_readNextEvent(tracefilePtr.getPointer() );
-
+ eventState = ltt_readNextEvent( tracefilePtr.getPointer() );
// If the event state is sane populate it
if (eventState == EOK) {
populateEventInformation();
}
-
+
return eventState;
}
*
* @return LTT read status, as defined in Jni_C_Common
*
- * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
*/
public int seekToTime(JniTime seekTime) {
// Ask Ltt to read the next event for this particular tracefile
*
* @return LTT read status, as defined in Jni_C_Common
*
- * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
*/
public int seekOrFallBack(JniTime seekTime) {
// Save the old time
- JniTime oldTime = eventTime;
+ JniTime oldTime = new JniTime(eventTime);
// Call seek to move ahead
// Save the state for the return (eventState will be modified if we seek back)
*
* @return LTT read status, as defined in Jni_C_Common
*
- * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
*/
public int positionToFirstEvent() {
eventState = ltt_positionToFirstEvent(tracefilePtr.getPointer());
*
* @return Reference to the marker for this tracefile's event or null if none.
*
- * @see org.eclipse.linuxtools.lttng.jni.JniMarker
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniMarker
*/
public JniMarker requestEventMarker() {
- return markersMap.get(eventMarkerId);
+ return markersMap.get(getEventMarkerId());
}
/**
* @return Bytes array of raw data (contain raw C bytes).
*/
public byte[] requestEventContent() {
- byte dataContent[] = new byte[(int) eventDataSize];
+ byte dataContent[] = new byte[(int) getEventDataSize()];
- ltt_getDataContent(thisEventPtr.getPointer(), eventDataSize, dataContent);
+ ltt_getDataContent(thisEventPtr.getPointer(), getEventDataSize(), dataContent);
return dataContent;
}
*
* @return Reference to the JniMarker object for this event or null if none.
*
- * @see org.eclipse.linuxtools.lttng.jni.JniMarker
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniMarker
*/
public String requestEventSource() {
// *** TODO ***
* @param fieldId Position of the field to parse.
*
* @return Object that contain the parsed payload
+ *
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniParser
*/
public Object parseFieldById(int fieldId) {
return JniParser.parseField(this, fieldId);
* @param fieldName Position of the field to parse.
*
* @return Object that contain the parsed payload
+ *
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniParser
*/
public Object parseFieldByName(String fieldName) {
return JniParser.parseField(this, fieldName);
/**
* Method to parse all the event payload.<p>
*
- * @return HashMap<String, Object> which is the parsedContent objects and their name as key.
+ * @return HashMap<String, Object> which is the parsedContent objects and their name as key.
+ *
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniParser
*/
public HashMap<String, Object> parseAllFields() {
return JniParser.parseAllFields(this);
/*
* This function populates the event data with data from LTT
*
+ * NOTE : To get better performance, we copy very few data into memory here
+ *
*/
private void populateEventInformation() {
- if (thisEventPtr.getPointer() == NULL) {
- printlnC("Pointer is NULL, trace closed? (populateEventInformation)");
- }
- else {
- tracefilePtr = new Jni_C_Pointer( ltt_getTracefilePtr(thisEventPtr.getPointer()) );
- eventMarkerId = ltt_getEventMarkerId(thisEventPtr.getPointer());
-
- // Creation of time is a bit different, we need to pass the object
- // reference to C
- ltt_feedEventTime(thisEventPtr.getPointer(), eventTime);
-
- eventDataSize = ltt_getEventDataSize(thisEventPtr.getPointer());
- }
+ // We need to save the time, as it is not a primitive (can't be dynamically called in getter)
+ eventTime.setTime(ltt_getNanosencondsTime(thisEventPtr.getPointer() ));
}
- public int getEventMarkerId() {
- return eventMarkerId;
- }
-
public JniTime getEventTime() {
return eventTime;
}
+
+ // *** To get better performance, all getter belows call LTT directly ****
+ // That way, we can avoid copying data into memory
+ public int getEventMarkerId() {
+ return ltt_getEventMarkerId(thisEventPtr.getPointer());
+ }
public long getEventDataSize() {
- return eventDataSize;
+ return ltt_getEventDataSize(thisEventPtr.getPointer());
}
public HashMap<Integer, JniMarker> getMarkersMap() {
return markersMap;
}
-
/**
* Pointer to the parent LTTTracefile C structure.<br>
* <br>
*
* @return The actual (long converted) pointer or NULL.
*
- * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
*/
public Jni_C_Pointer getTracefilePtr() {
- return tracefilePtr;
+ return new Jni_C_Pointer( ltt_getTracefilePtr(thisEventPtr.getPointer()) );
}
/**
*
* @return The actual (long converted) pointer or NULL.
*
- * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
*/
public Jni_C_Pointer getEventPtr() {
return thisEventPtr;
*
* @return The parent tracefile
*
- * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
*/
public JniTracefile getParentTracefile() {
return parentTracefile;
*
* @return -1 if given event happens before, 0 if equal, 1 if passed event happens after.
*/
- //@Override
public int compareTo(JniEvent rightEvent ){
- JniEvent leftEvent = this;
+
+ // Note : this = left hand operand
+
// By default, we consider the current event to be older.
int eventComparaison = -1;
// Test against null before performing anything
if ( rightEvent != null ) {
// Compare the timestamp first
- eventComparaison = leftEvent.getEventTime().compareTo( rightEvent.getEventTime() );
+ eventComparaison = this.getEventTime().compareTo( rightEvent.getEventTime() );
// If timestamp is equal, compare the parent tracefile ("event type")
- if ( (eventComparaison == 0) && ( !leftEvent.parentTracefile.equals(rightEvent.parentTracefile)) ) {
+ if ( (eventComparaison == 0) && ( !this.parentTracefile.equals(rightEvent.parentTracefile)) ) {
eventComparaison = 1;
}
}
String returnData = "";
returnData += "tracefilePtr : " + tracefilePtr + "\n";
- returnData += "eventMarkerId : " + eventMarkerId + "\n";
+ returnData += "eventMarkerId : " + getEventMarkerId() + "\n";
returnData += "eventTime : " + eventTime.getReferenceToString() + "\n";
returnData += " seconds : " + eventTime.getSeconds() + "\n";
returnData += " nanoSeconds : " + eventTime.getNanoSeconds() + "\n";
- returnData += "eventDataSize : " + eventDataSize + "\n";
+ returnData += "eventDataSize : " + getEventDataSize() + "\n";
returnData += "markersMap : " + markersMap.keySet() + "\n"; // Hack to avoid ending up with markersMap.toString()
return returnData;
+package org.eclipse.linuxtools.lttng.jni;
/*******************************************************************************
* Copyright (c) 2009 Ericsson
*
* William Bourque (wbourque@gmail.com) - Initial API and implementation
*******************************************************************************/
-package org.eclipse.linuxtools.lttng.jni;
/**
* <b><u>JniException</u></b>
+package org.eclipse.linuxtools.lttng.jni;
/*******************************************************************************
* Copyright (c) 2009 Ericsson
*
* William Bourque (wbourque@gmail.com) - Initial API and implementation
*******************************************************************************/
-package org.eclipse.linuxtools.lttng.jni;
import java.util.ArrayList;
import java.util.HashMap;
*
* @return The actual (long converted) pointer or NULL
*
- * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
*/
public Jni_C_Pointer getMarkerPtr() {
return thisMarkerPtr;
+package org.eclipse.linuxtools.lttng.jni;
/*******************************************************************************
* Copyright (c) 2009 Ericsson
*
* William Bourque (wbourque@gmail.com) - Initial API and implementation
*******************************************************************************/
-package org.eclipse.linuxtools.lttng.jni;
/**
* <b><u>JniMarkerField</u></b> <p>
*
* @return The actual (long converted) pointer or NULL
*
- * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
*/
public Jni_C_Pointer getMarkerFieldPtr() {
return thisMarkerFieldPtr;
+package org.eclipse.linuxtools.lttng.jni;
/*******************************************************************************
* Copyright (c) 2009 Ericsson
*
* William Bourque (wbourque@gmail.com) - Initial API and implementation
*******************************************************************************/
-package org.eclipse.linuxtools.lttng.jni;
import java.util.HashMap;
import java.util.Iterator;
static {
System.loadLibrary("lttvtraceread");
}
-
+
+ // *** HACK ***
+ // We cannot use "Object" directly as java does not support swapping primitive value
+ // We either need to create a new object type or to use a "non-primitive" type that have "Setter()" functions
+ // Another (ugly) hack would be to pass an array to modify the reference's reference.
+ // ***
+ private static ParsedObjectContent parsedData = new ParsedObjectContent();
+
/*
* Default constructor is forbidden
*/
*
* @return An Object that contain the JniEvent payload parsed by the C, or null, if if was impossible to parse (i.e., wrong position)
*
- * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
*/
static public Object parseField(JniEvent eventToParse, int fieldPosition) {
return null;
}
- // *** HACK ***
- // We cannot use "Object" directly as java does not support swapping primitive value
- // We either need to create a new object type or to use a "non-primitive" type that have "Setter()" functions
- // Another (ugly) hack would be to pass an array to modify the reference's reference.
- // ***
- ParsedObjectContent parsedData = new ParsedObjectContent();
+ JniMarkerField tmpField = eventToParse.requestEventMarker().getMarkerFieldsArrayList().get(fieldPosition);
// Call the parsing function in C. The result will be put in parsedData object
- ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), eventToParse.requestEventMarker().getMarkerFieldsArrayList().get(fieldPosition).getMarkerFieldPtr().getPointer() );
+ ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), tmpField.getMarkerFieldPtr().getPointer() );
return parsedData.getData();
}
*
* @return An Object that contain the JniEvent payload parsed by the C, or null, if if was impossible to parse (i.e., wrong position)
*
- * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
*/
static public Object parseField(JniEvent eventToParse, String fieldName) {
return null;
}
- // *** HACK ***
- // We cannot use "Object" directly as java does not support swapping on primitive value
- // We either need to create a new object type or to use a "non-primitive" type that have "Setter()" functions
- // Another (ugly) hack would be to pass an array to modify the reference's reference.
- // ***
- ParsedObjectContent parsedData = new ParsedObjectContent();
-
ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), tmpField.getMarkerFieldPtr().getPointer() );
return parsedData.getData();
* @param eventToParse The jni event we want to parse.
* @return An HashMap of Object that contain the is the JniEvent's payload parsed by the C
*
- * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
*/
static public HashMap<String, Object> parseAllFields(JniEvent eventToParse) {
HashMap<String,JniMarkerField> markerFieldData = eventToParse.requestEventMarker().getMarkerFieldsHashMap();
// Or even safer, use HashMap constructor to do so :
HashMap<String, Object> parsedDataMap = new HashMap<String, Object>(markerFieldData);
- // *** HACK ***
- // We cannot use "Object" directly as java does not support swapping on primitive value
- // We either need to create a new object type or to use a "non-primitive" type that have "Setter()" functions
- // ***
- ParsedObjectContent parsedData = new ParsedObjectContent();
-
- String newKey = null;
- JniMarkerField newValue = null;
- Iterator<String> iterator = markerFieldData.keySet().iterator();
-
+ String newKey = null;
+ JniMarkerField newMarkerField = null;
+ Iterator<String> iterator = markerFieldData.keySet().iterator();
+
while ( iterator.hasNext() ) {
newKey = iterator.next();
- newValue = markerFieldData.get(newKey);
+ newMarkerField = markerFieldData.get(newKey);
// Call the C to parse the data
- ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), newValue.getMarkerFieldPtr().getPointer() );
+ ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), newMarkerField.getMarkerFieldPtr().getPointer() );
// Save the result into the HashMap
- parsedDataMap.put(newValue.getField(), parsedData.getData() );
+ parsedDataMap.put(newMarkerField.getField(), parsedData.getData() );
}
return parsedDataMap;
* @param formatToAdd The format of the raw data
*/
@SuppressWarnings("unused")
- static private void addStringToParsingFromC(Object contentHolder, String fieldName, String stringToAdd) {
+ static private void addStringToParsingFromC(Object contentHolder, String stringToAdd) {
((ParsedObjectContent)contentHolder).setData( stringToAdd);
}
* @param formatToAdd The format of the raw data
*/
@SuppressWarnings("unused")
- static private void addLongPointerToParsingFromC(Object contentHolder, String fieldName, long pointerToAdd) {
+ static private void addLongPointerToParsingFromC(Object contentHolder, long pointerToAdd) {
((ParsedObjectContent)contentHolder).setData( new Jni_C_Pointer((long) pointerToAdd));
}
* @param formatToAdd The format of the raw data
*/
@SuppressWarnings("unused")
- static private void addIntPointerToParsingFromC(Object contentHolder, String fieldName, long pointerToAdd) {
+ static private void addIntPointerToParsingFromC(Object contentHolder, long pointerToAdd) {
((ParsedObjectContent)contentHolder).setData( new Jni_C_Pointer((int) pointerToAdd));
}
* @param formatToAdd The format of the raw data
*/
@SuppressWarnings("unused")
- static private void addShortToParsingFromC(Object contentHolder, String fieldName, short shortToAdd) {
+ static private void addShortToParsingFromC(Object contentHolder, short shortToAdd) {
((ParsedObjectContent)contentHolder).setData( new Short(shortToAdd));
}
* @param formatToAdd The format of the raw data
*/
@SuppressWarnings("unused")
- static private void addIntegerToParsingFromC(Object contentHolder, String fieldName, int intToAdd) {
+ static private void addIntegerToParsingFromC(Object contentHolder, int intToAdd) {
((ParsedObjectContent)contentHolder).setData( new Integer(intToAdd));
}
* @param formatToAdd The format of the raw data
*/
@SuppressWarnings("unused")
- static private void addLongToParsingFromC(Object contentHolder, String fieldName, long longToAdd) {
+ static private void addLongToParsingFromC(Object contentHolder, long longToAdd) {
((ParsedObjectContent)contentHolder).setData( new Long(longToAdd));
}
* @param formatToAdd The format of the raw data
*/
@SuppressWarnings("unused")
- static private void addFloatToParsingFromC(Object contentHolder, String fieldName, float floatToAdd) {
+ static private void addFloatToParsingFromC(Object contentHolder, float floatToAdd) {
((ParsedObjectContent)contentHolder).setData( new Float(floatToAdd));
}
* @param formatToAdd The format of the raw data
*/
@SuppressWarnings("unused")
- static private void addDoubleToParsingFromC(Object contentHolder, String fieldName, double doubleToAdd) {
+ static private void addDoubleToParsingFromC(Object contentHolder, double doubleToAdd) {
((ParsedObjectContent)contentHolder).setData( new Double(doubleToAdd));
}
+package org.eclipse.linuxtools.lttng.jni;
/*******************************************************************************
* Copyright (c) 2009 Ericsson
*
* William Bourque (wbourque@gmail.com) - Initial API and implementation
*******************************************************************************/
-package org.eclipse.linuxtools.lttng.jni;
/**
* <b><u>JniTime</u></b>
public long getTime() {
return time;
}
-
+
+ /**
+ * Changes the current time for this object<p>
+ *
+ * @param newTime New time to set, in nanoseconds.
+ */
+ public void setTime(long newTime) {
+ time = newTime;
+ }
+
+ /*
+ * Populate this time object
+ *
+ * Note: This function is called from C side.
+ *
+ * @param newTime The time we want to populate
+ */
+ @SuppressWarnings("unused")
+ private void setTimeFromC(long newTime) {
+ time = newTime;
+ }
+
/**
* Comparaison operator smaller or equal than "<=" .<p>
*
* @return int of value -1, 0 or 1, as the pased argument is bigger, equal or smaller than this time
*/
public int compareTo(JniTime right) {
+ long leftTime = this.getTime();
+ long rightTime = right.getTime();
- JniTime left = this;
-
- if ( left.getTime() < right.getTime() ) {
+ if ( leftTime < rightTime ) {
return -1;
}
- else if ( left.getTime() > right.getTime() ) {
- return 1;
+ else if ( leftTime > rightTime ) {
+ return 1;
}
else {
return 0;
}
}
-
- /*
- * Populate this time object
- *
- * Note: This function is called from C side.
- *
- * @param newTime The time we want to populate
- */
- @SuppressWarnings("unused")
- private void setTimeFromC(long newTime) {
- time = newTime;
- }
/**
* toString() method.
+package org.eclipse.linuxtools.lttng.jni;
/*******************************************************************************
* Copyright (c) 2009 Ericsson
*
* William Bourque (wbourque@gmail.com) - Initial API and implementation
*******************************************************************************/
-package org.eclipse.linuxtools.lttng.jni;
import java.util.HashMap;
import java.util.Iterator;
* </ul>
*/
public class JniTrace extends Jni_C_Common {
-
+
+ private final static boolean DEFAULT_LTT_DEBUG = false;
+
// Internal C pointer of the JniTrace used in LTT
private Jni_C_Pointer thisTracePtr = new Jni_C_Pointer();
// This variable will hold the content of the "last" event we read
private JniEvent currentEvent = null;
+ // Should we print debug in the C library or not?
+ private boolean printLttDebug = DEFAULT_LTT_DEBUG;
+
// Open/close native functions
- private native long ltt_openTrace(String pathname);
+ private native long ltt_openTrace(String pathname, boolean printDebug);
private native void ltt_closeTrace(long tracePtr);
// Native access functions
private native long ltt_getStartFreq(long tracePtr);
private native long ltt_getStartTimestampCurrentCounter(long tracePtr);
private native long ltt_getStartMonotonic(long tracePtr);
-
+
// Native function to fill out startTime
private native void ltt_feedStartTime(long tracePtr, JniTime startTime);
-
+
// Native function to fill out startTimeFromTimestampCurrentCounter
private native void ltt_feedStartTimeFromTimestampCurrentCounter(long tracePtr, JniTime startTime);
* This constructor also opens the trace.
*
* @param newpath The <b>directory</b> of the trace to be opened
+ * @param newPrintDebug Should the debug information be printed in the LTT C library
*
* @exception JniException
*/
- public JniTrace(String newpath) throws JniException {
+ public JniTrace(String newpath, boolean newPrintDebug) throws JniException {
tracepath = newpath;
thisTracePtr = new Jni_C_Pointer();
+ printLttDebug = newPrintDebug;
openTrace(newpath);
}
eventsHeap = new PriorityQueue<JniEvent>( oldTrace.eventsHeap.size());
eventsHeap = oldTrace.eventsHeap;
+
+ printLttDebug = oldTrace.printLttDebug;
}
/**
* Constructor, using C pointer.<p>
*
* @param newPtr The pointer to an already opened LttTrace C structure.
+ * @param newPrintDebug Should the debug information be printed in the LTT C library
*
* @exception JniException
*
- * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
*/
- public JniTrace(Jni_C_Pointer newPtr) throws JniException {
+ public JniTrace(Jni_C_Pointer newPtr, boolean newPrintDebug) throws JniException {
thisTracePtr = newPtr;
+ printLttDebug = newPrintDebug;
// Populate our trace
populateTraceInformation();
}
// Call the LTT to open the trace
- long newPtr = ltt_openTrace(tracepath);
+ long newPtr = ltt_openTrace(tracepath, printLttDebug);
if (newPtr == NULL) {
throw new JniOpenTraceFailedException("Error while opening trace. Is the tracepath correct? (openTrace)");
}
// the tracefile fill itself with LTT data while being constructed
try {
newTracefile = new JniTracefile( new Jni_C_Pointer(tracefilePtr), this );
- tracefilesMap.put(tracefileName + newTracefile.getCpuNumber(), newTracefile);
+ tracefilesMap.put( (tracefileName + newTracefile.getCpuNumber()), newTracefile);
}
catch(JniTracefileWithoutEventException e) {
printlnC("JniTracefile " + tracefileName + " has no event (addTracefileFromC). Ignoring.");
printlnC("Failed to add tracefile " + tracefileName + " to tracefilesMap!(addTracefileFromC)\n\tException raised : " + e.toString() );
}
}
-
+
/**
* Return the top event in the events stack, determined by timestamp, in the trace (all the tracefiles).<p>
*
*
* @return The top event in the stack or null if no event is available.
*
- * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
*/
public JniEvent findNextEvent() {
return eventsHeap.peek();
*
* @return The next event in the trace or null if no event is available.
*
- * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
*/
public JniEvent readNextEvent() {
// Get the "next" event on the top of the heap but DO NOT remove it
*
* @return The next event in the tracefile or null if no event is available.
*
- * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
- * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
*/
public JniEvent readNextEvent(JniTracefile targetTracefile) {
JniEvent returnedEvent = null;
*
* @param seekTime The time where we want to seek to
*
- * @see org.eclipse.linuxtools.lttng.jni.JniTime
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
*/
public void seekToTime(JniTime seekTime) {
* @param targetTracefile The tracefile object to read from
* @param seekTime The time where we want to seek to
*
- * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
- * @see org.eclipse.linuxtools.lttng.jni.JniTime
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
*/
public void seekToTime(JniTime seekTime, JniTracefile targetTracefile) {
// Invalidate the current read event
currentEvent = null;
// Remove from the event related to this tracefile from the event heap, if it exists.
- // WARNING : This only safe as long getCurrentEvent() never return "null" in any case.
+ // WARNING : This is only safe as long getCurrentEvent() never return "null" in any case.
eventsHeap.remove(targetTracefile.getCurrentEvent() );
// Perform the actual seek on the tracefile
*
* @return The event just after the seeked time or null if none available.
*
- * @see org.eclipse.linuxtools.lttng.jni.JniEvent
- * @see org.eclipse.linuxtools.lttng.jni.JniTime
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
*/
public JniEvent seekAndRead(JniTime seekTime) {
JniEvent returnedEvent = null;
*
* @return The event just after the seeked time or null if none available.
*
- * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
- * @see org.eclipse.linuxtools.lttng.jni.JniTime
- * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
*/
public JniEvent seekAndRead(JniTime seekTime, JniTracefile targetTracefile) {
seekToTime(seekTime, targetTracefile);
*
* @return The tracefile found or null if none.
*
- * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
*/
public JniTracefile requestTracefileByName(String tracefileName) {
return tracefilesMap.get(tracefileName);
*
* @return Event of the tracefile or null if none found.
*
- * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
*/
public JniEvent requestEventByName(String tracefileName) {
JniEvent returnValue = null;
*
* @return Time of the last event read
*
- * @see org.eclipse.linuxtools.lttng.jni.JniTime
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
*/
public JniTime getCurrentEventTimestamp() {
JniTime returnedTime = null;
*
* @return The actual (long converted) pointer or NULL.
*
- * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
*/
public Jni_C_Pointer getTracePtr() {
return thisTracePtr;
}
-
+
+ /**
+ * Return boolean value saying if the debug is enabled in LTT or not.<p>
+ *
+ * Note : this need to be set at construction.
+ *
+ * @return If the debug is set or not
+ */
+ public boolean isPrintingLttDebug() {
+ return printLttDebug;
+ }
+
/**
* Print information for all the tracefiles associated with this trace.
* <u>Intended to debug</u><p>
* This function will call Ltt to print, so information printed will be the
* one from the C structure, not the one populated in java.
*
- * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
*/
public void printAllTracefilesInformation() {
JniTracefile tracefile = null;
+package org.eclipse.linuxtools.lttng.jni;
/*******************************************************************************
* Copyright (c) 2009 Ericsson
*
* William Bourque (wbourque@gmail.com) - Initial API and implementation
*******************************************************************************/
-package org.eclipse.linuxtools.lttng.jni;
import java.util.HashMap;
*
* @exception JniException
*
- * @see org.eclipse.linuxtools.lttng.jni.JniTrace
- * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTrace
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
*/
public JniTracefile(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException {
thisTracefilePtr = newPtr;
*
* @return LTT read status, as defined in Jni_C_Common
*
- * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
*/
public int readNextEvent() {
return currentEvent.readNextEvent();
*
* @return LTT read status, as defined in Jni_C_Common
*
- * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
*/
public int seekToTime(JniTime seekTime) {
return currentEvent.seekToTime(seekTime);
*
* @return The parent trace
*
- * @see org.eclipse.linuxtools.lttng.jni.JniTrace
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTrace
*/
public JniTrace getParentTrace() {
return parentTrace;
*
* @return The actual (long converted) pointer or NULL.
*
- * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+ * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
*/
public Jni_C_Pointer getTracefilePtr() {
return thisTracefilePtr;
+package org.eclipse.linuxtools.lttng.jni;
/*******************************************************************************
* Copyright (c) 2009 Ericsson
*
* William Bourque (wbourque@gmail.com) - Initial API and implementation
*******************************************************************************/
-package org.eclipse.linuxtools.lttng.jni;
/**
* <b><u>Jni_C_Common</u></b>
package org.eclipse.linuxtools.lttng.jni;
+
/**
* <b><u>Jni_C_Pointer</u></b>
* <p>
public StateDataRequest(TmfTimeRange range, long offset, int nbEvents,
int maxBlockSize, IStateDataRequestListener listener,
StateManager manager) {
-
- super(range, offset, nbEvents, maxBlockSize);
+
+ super(range, nbEvents, maxBlockSize);
+ //super(0, nbEvents, maxBlockSize);
this.manager = manager;
if (listener != null && !listeners.contains(listener)) {
listeners.add(listener);
*/
public class StateManager extends Observable {
- private static final long LTTNG_STATE_SAVE_INTERVAL = 50000L;
+ private static final long LTTNG_STATE_SAVE_INTERVAL = 5000000L;
// These are used in the building of the data request.
private static final long DEFAULT_OFFSET = 0L;
|| (eventTime.getValue() > logRange.getEndTime().getValue())) {
return null;
}
-
+
// The GUI can have time limits lower than this log, since GUI can
// handle multiple logs
if ((eventTime.getValue() < logRange.getStartTime().getValue())) {
eventTime = logRange.getStartTime();
}
-
+
// Sort the checkpoints, required before the binary search
Collections.sort(timestampCheckpointsList);
// Initiate the compare with a checkpoint containing the target time
@Override
public void handleData() {
TmfEvent[] result = getData();
-
+
evt[0] = (result.length > 0) ? result[0] : null;
// Dispatch information for Event processing
stateIn.processEvent(evt[0]);
import org.eclipse.linuxtools.lttng.TraceDebug;
import org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.event.LttngEventContent;
+import org.eclipse.linuxtools.lttng.event.LttngEventField;
import org.eclipse.linuxtools.lttng.jni.JniTrace;
import org.eclipse.linuxtools.lttng.state.evProcessor.AbsEventProcessorFactory;
import org.eclipse.linuxtools.lttng.state.evProcessor.EventProcessorProxy;
}
LttngEvent trcEvent = (LttngEvent) tmfEvent;
- TmfEventField[] fields = trcEvent.getContent().getFields();
+// LttngEventField[] fields = ((LttngEventContent)trcEvent.getContent()).getFields();
- if (fields != null) {
+ if (trcEvent != null) {
String inEventName = trcEvent.getMarkerName();
// String inChannel = trcEvent.getChannelName();
// TraceDebug.debug("Event: " + inEventName);
* @param expectedNumFields
* @return
*/
- protected Long getAFieldLong(LttngEvent trcEvent, LttngTraceState traceSt,
- Fields expectedField) {
+ protected Long getAFieldLong(LttngEvent trcEvent, LttngTraceState traceSt, Fields expectedField) {
Long fieldVal = null;
+
+ String fieldname = expectedField.getInName();
+ LttngEventField field = ((LttngEventContent) trcEvent.getContent()).getField(fieldname);
+
+// if ( field == null ) {
+// System.out.println("****************** JOIE : " + fieldname);
+// System.out.println("***************** CONTENT : " + ((LttngEventContent) trcEvent.getContent()).toString());
+// }
+// else {
+ Object fieldObj = field.getValue();
+ if ( (fieldObj instanceof Long) || (fieldObj instanceof Integer) ) {
+ // Expected numeric value found
+ fieldVal = (Long) field.getValue();
+ }
+ else {
+ if (TraceDebug.isDEBUG()) {
+ TraceDebug.debug("Unexpected field Type. Expected: Long, Received: "+ fieldObj.getClass().getSimpleName());
+ }
+ }
+// }
+
+ /*
// TmfEventField[] fields = trcEvent.getContent().getFields();
TmfEventField[] fields = ((LttngEventContent) trcEvent.getContent())
.getFields(trcEvent);
}
}
}
+ */
- if (fieldVal == null) {
- if (TraceDebug.isDEBUG()) {
- sendNoFieldFoundMsg(fields, expectedFieldName);
- }
- }
+// if (fieldVal == null) {
+// if (TraceDebug.isDEBUG()) {
+// sendNoFieldFoundMsg(((LttngEventContent) trcEvent.getContent()).getFields(), fieldname);
+// }
+// }
return fieldVal;
}
protected String getAFieldString(LttngEvent trcEvent,
LttngTraceState traceSt, Fields expectedField) {
String fieldVal = null;
+
+ String fieldname = expectedField.getInName();
+ LttngEventField field = ((LttngEventContent) trcEvent.getContent()).getField(fieldname);
+
+ Object fieldObj = field.getValue();
+ if (fieldObj instanceof String) {
+ // Expected numeric value found
+ fieldVal = (String) field.getValue();
+ }
+ else {
+ if (TraceDebug.isDEBUG()) {
+ TraceDebug.debug("Unexpected field Type. Expected: String, Received: "+ fieldObj.getClass().getSimpleName());
+ }
+ }
+
+ /*
// TmfEventField[] fields = trcEvent.getContent().getFields();
TmfEventField[] fields = ((LttngEventContent) trcEvent.getContent())
.getFields(trcEvent);
}
}
}
-
- if (fieldVal == null) {
- if (TraceDebug.isDEBUG()) {
- sendNoFieldFoundMsg(fields, expectedFieldName);
- }
- }
+ */
+
+// if (fieldVal == null) {
+// if (TraceDebug.isDEBUG()) {
+// sendNoFieldFoundMsg(((LttngEventContent) trcEvent.getContent()).getFields(), fieldname);
+// }
+// }
return fieldVal;
}
sb.append(" number of fields: " + fields.length + "Fields: ");
for (int i = 0; i < fields.length; i++) {
field = (LttngEventField) fields[i];
- sb.append(field.getName() + " ");
+ sb.append(field.getId() + " ");
}
TraceDebug.debug(sb.toString(), 5);
LttngExecutionState exe_state = new LttngExecutionState();
exe_state.setExec_mode(execMode);
exe_state.setExec_submode(submode);
- exe_state.setEntry_Time(eventTime);
- exe_state.setChange_Time(eventTime);
+ exe_state.setEntry_Time(eventTime.getValue());
+ exe_state.setChange_Time(eventTime.getValue());
exe_state.setCum_cpu_time(0L);
exe_state.setProc_status(process.getState().getProc_status());
process.pushToExecutionStack(exe_state);
//The process state is updated within the pop method
process.popFromExecutionStack();
- process.getState().setChange_Time(eventTime);
+ process.getState().setChange_Time(eventTime.getValue());
}
protected void irq_push_mode(LttngIRQState irqst, IRQMode state) {
Long cpu, Long pid, Long tgid, String name,
final TmfTimestamp timestamp) {
LttngProcessState process;
- process = new LttngProcessState(cpu, pid, tgid, name, timestamp, traceSt.getTraceId());
+ process = new LttngProcessState(cpu, pid, tgid, name, timestamp.getValue(), traceSt.getTraceId());
traceSt.addProcessState(process);
return process;
}
process.getState().setProc_status(
ProcessStatus.LTTV_STATE_WAIT);
process.getState().setChange_Time(
- trcEvent.getTimestamp());
+ trcEvent.getTimestamp().getValue());
process.getState().setEntry_Time(
- trcEvent.getTimestamp());
+ trcEvent.getTimestamp().getValue());
}
} else {
if (process.getState().getProc_status() == ProcessStatus.LTTV_STATE_EXIT) {
process.getState().setProc_status(
ProcessStatus.LTTV_STATE_ZOMBIE);
process.getState().setChange_Time(
- trcEvent.getTimestamp());
+ trcEvent.getTimestamp().getValue());
} else {
if ((state_out != null)
&& (state_out.longValue() == 0L)) {
}
process.getState().setChange_Time(
- trcEvent.getTimestamp());
+ trcEvent.getTimestamp().getValue());
}
if ((state_out != null)
process.getState().setProc_status(
ProcessStatus.LTTV_STATE_DEAD);
process.getState().setChange_Time(
- trcEvent.getTimestamp());
+ trcEvent.getTimestamp().getValue());
}
}
}
traceSt.getRunning_process().put(cpu, process);
process.getState().setProc_status(ProcessStatus.LTTV_STATE_RUN);
- process.getState().setChange_Time(eventTime);
+ process.getState().setChange_Time(eventTime.getValue());
process.setCpu(cpu);
// process->state->s = LTTV_STATE_RUN;
// if(process->usertrace)
if (child_process == null) {
child_process = create_process(traceSt, cpu, child_pid,
child_tgid, timeStamp);
- child_process.setPpid(process.getPid(), timeStamp);
+ child_process.setPpid(process.getPid(), timeStamp.getValue());
} else {
/*
* The process has already been created : due to time
es
.setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE
.getInName());
- es.setEntry_Time(timestamp);
- es.setChange_Time(timestamp);
+ es.setEntry_Time(timestamp.getValue());
+ es.setChange_Time(timestamp.getValue());
es.setCum_cpu_time(0L);
if (es.getProc_status() == ProcessStatus.LTTV_STATE_UNNAMED) {
es.setProc_status(ProcessStatus.LTTV_STATE_WAIT);
es
.setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE
.getInName());
- es.setEntry_Time(timestamp);
- es.setChange_Time(timestamp);
+ es.setEntry_Time(timestamp.getValue());
+ es.setChange_Time(timestamp.getValue());
es.setCum_cpu_time(0L);
if (es.getProc_status() == ProcessStatus.LTTV_STATE_UNNAMED) {
es.setProc_status(ProcessStatus.LTTV_STATE_RUN);
es
.setExec_submode(ExecutionSubMode.LTTV_STATE_SUBMODE_NONE
.getInName());
- es.setEntry_Time(timestamp);
- es.setChange_Time(timestamp);
+ es.setEntry_Time(timestamp.getValue());
+ es.setChange_Time(timestamp.getValue());
es.setCum_cpu_time(0L);
es.setProc_status(ProcessStatus.LTTV_STATE_WAIT);
Long tgid;
String command;
Long cpu = trcEvent.getCpuId();
+
LttngProcessState process = traceSt.getRunning_process().get(
cpu);
LttngProcessState parent_process;
String type;
// String mode, submode, status;
LttngExecutionState es;
-
+
/* PID */
pid = getAFieldLong(trcEvent, traceSt, Fields.LTT_FIELD_PID);
process = create_process(traceSt, cpu, pid, tgid,
command, eventTime);
if (parent_process != null) {
- process.setPpid(parent_process.getPid(), eventTime);
+ process.setPpid(parent_process.getPid(), eventTime.getValue());
}
/* Keep the stack bottom : a running user mode */
package org.eclipse.linuxtools.lttng.state.model;
import org.eclipse.linuxtools.lttng.state.StateStrings;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
/**
* <b><u>LttngExecutionState</u></b>
// ========================================================================
// Data
// =======================================================================
- private TmfTimestamp entry_LttTime = null;
- private TmfTimestamp change_LttTime = null;
+ private Long entry_LttTime = null;
+ private Long change_LttTime = null;
private Long cum_cpu_time_Timens = null;
private StateStrings.ProcessStatus proc_status = StateStrings.ProcessStatus.LTTV_STATE_UNNAMED;
// ProcessStatus and ExecutionMode are enum, and so shouldn't be a problem to use their reference
newState.proc_status = this.proc_status;
newState.exec_mode = this.exec_mode;
-
- // No clonable implemented in TMF, we will use copy constructor
- // NOTE : we GOT to check for null to avoid crashing on null pointer here!
- if ( this.entry_LttTime != null ) {
- newState.entry_LttTime = new TmfTimestamp(this.entry_LttTime);
- }
-
- if ( this.change_LttTime != null ) {
- newState.change_LttTime = new TmfTimestamp(this.change_LttTime);
- }
+ newState.entry_LttTime = this.entry_LttTime;
+ newState.change_LttTime = this.change_LttTime;
}
catch ( CloneNotSupportedException e ) {
System.out.println("Cloning failed with : " + e.getMessage() );
/**
* @return the entry_LttTime
*/
- public TmfTimestamp getEntry_LttTime() {
+ public Long getEntry_LttTime() {
return entry_LttTime;
}
* @param entryLttTime
* the entry_LttTime to set
*/
- public void setEntry_Time(TmfTimestamp entryLttTime) {
+ public void setEntry_Time(Long entryLttTime) {
entry_LttTime = entryLttTime;
}
/**
* @return the change_LttTime
*/
- public TmfTimestamp getChange_LttTime() {
+ public Long getChange_LttTime() {
return change_LttTime;
}
* @param changeLttTime
* the change_LttTime to set
*/
- public void setChange_Time(TmfTimestamp changeLttTime) {
+ public void setChange_Time(Long changeLttTime) {
change_LttTime = changeLttTime;
}
import org.eclipse.linuxtools.lttng.state.StateStrings.ExecutionMode;
import org.eclipse.linuxtools.lttng.state.StateStrings.ExecutionSubMode;
import org.eclipse.linuxtools.lttng.state.StateStrings.ProcessStatus;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
/**
* <b>LttngProcessState</b>
private Long pid = null;
private Long tgid = null;
private String name = null;
- private TmfTimestamp creation_time = null;
+ private Long creation_time = null;
private String brand = null;
private StateStrings.ProcessType type = null;
private Long current_function = null;
private Long ppid = null;
- private TmfTimestamp insertion_time = null;
+ private Long insertion_time = null;
private String pid_time = null;
private Long free_events = null;
private LttngExecutionState state = null; // top of stack
// ========================================================================
// Constructor
// =======================================================================
- public LttngProcessState(TmfTimestamp startTime) {
+ public LttngProcessState(Long startTime, String traceId) {
this.cpu = 0L;
this.pid = 0L;
this.tgid = 0L;
}
public LttngProcessState(Long cpu, Long pid, Long tgid,
- String name, TmfTimestamp startTime, String traceId) {
+ String name, Long startTime, String traceId) {
this.cpu = cpu;
this.pid = pid;
this.tgid = tgid;
this.type = StateStrings.ProcessType.LTTV_STATE_USER_THREAD;
this.current_function = 0L;
this.ppid = 0L;
- // creation time defined when parent pid is known
- // calling the setCreation_time method adjust the pid_time string
- setCreation_time(new TmfTimestamp());
+ this.creation_time = 0L;
this.free_events = 0L;
// Initialise stack
newState.userTrace = this.userTrace;
newState.target_pid = this.target_pid;
newState.trace_id = this.trace_id;
-
- // No clonable implemented in TMF, we will use copy constructor
- // NOTE : we GOT to check for null to avoid crashing on null pointer here!
- if ( this.creation_time != null ) {
- newState.creation_time = new TmfTimestamp(this.creation_time);
- }
-
- if ( this.creation_time != null ) {
- newState.insertion_time = new TmfTimestamp(this.insertion_time);
- }
+ newState.creation_time = this.creation_time;
+ newState.insertion_time = this.insertion_time;
// Call clone on our own object is safe as Long it implements Clonable
newState.state = (LttngExecutionState)this.state.clone();
* @param ppid
* the ppid to set
*/
- public void setPpid(Long ppid, TmfTimestamp creationTime) {
+ public void setPpid(Long ppid, Long creationTime) {
if (ppid != null) {
this.ppid = ppid;
}
/**
* @return the creation_time
*/
- public TmfTimestamp getCreation_time() {
+ public Long getCreation_time() {
return creation_time;
}
* @param creationTime
* the creation_time to set
*/
- public void setCreation_time(TmfTimestamp creationTime) {
+ public void setCreation_time(Long creationTime) {
if ( (creationTime != null) && (pid != null) ) {
creation_time = creationTime;
StringBuilder sb = new StringBuilder(this.pid.toString() + "-"
/**
* @return the insertion_time
*/
- public TmfTimestamp getInsertion_time() {
+ public Long getInsertion_time() {
return insertion_time;
}
* @param insertionTime
* the insertion_time to set
*/
- public void setInsertion_time(TmfTimestamp insertionTime) {
+ public void setInsertion_time(Long insertionTime) {
insertion_time = insertionTime;
}
import org.eclipse.linuxtools.lttng.state.StateStrings.IRQMode;
import org.eclipse.linuxtools.lttng.state.StateStrings.ProcessStatus;
import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
/**
* <b><u>LttngTraceState</u></b>
private Long save_interval = null;
- private TmfTimestamp max_time_state_recomputed_in_seek = null;
+ private Long max_time_state_recomputed_in_seek = null;
private boolean has_precomputed_states = false;
private HashMap<ProcessStateKey, LttngProcessState> processes = new HashMap<ProcessStateKey, LttngProcessState>();
// Basic value only need to be assigned while cloning
newState.has_precomputed_states = this.has_precomputed_states;
newState.nb_events = this.nb_events;
-
- // No clonable implemented in TMF, we will use copy constructor
- // NOTE : we GOT to check for null to avoid crashing on null pointer
- // here!
- if (this.max_time_state_recomputed_in_seek != null) {
- newState.max_time_state_recomputed_in_seek = new TmfTimestamp(
- this.max_time_state_recomputed_in_seek);
- }
+ newState.max_time_state_recomputed_in_seek = this.max_time_state_recomputed_in_seek;
// Clone should work correctly for all stack object that contain
// basic java object (String, Long, etc...)
traceId = inputDataRef.getTraceId();
// max time
- setMax_time_state_recomputed_in_seek(new TmfTimestamp());
+ max_time_state_recomputed_in_seek = 0L;
// reset cpu_states
cpu_states.clear();
// bdev states
bdev_states.clear();
-
- // JniTrace State
- init_state(numCpus);
-
- }
-
- public void init_state(int numCpus) {
+
processes.clear();
nb_events = 0;
/* Put the per cpu running_process to beginning state : process 0. */
for (Long i = 0L; i < numCpus; i++) {
- LttngProcessState process = new LttngProcessState(timeWin
- .getStartTime());
+ LttngProcessState process = new LttngProcessState(timeWin.getStartTime().getValue(), traceId );
/*
* We are not sure is it's a kernel thread or normal thread, put the
return inputDataRef;
}
- public TmfTimestamp getMax_time_state_recomputed_in_seek() {
+ public Long getMax_time_state_recomputed_in_seek() {
return max_time_state_recomputed_in_seek;
}
public void setMax_time_state_recomputed_in_seek(
- TmfTimestamp maxTimeStateRecomputedInSeek) {
+ Long maxTimeStateRecomputedInSeek) {
max_time_state_recomputed_in_seek = maxTimeStateRecomputedInSeek;
}
package org.eclipse.linuxtools.lttng.trace;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Vector;
+
import org.eclipse.linuxtools.lttng.LttngException;
import org.eclipse.linuxtools.lttng.event.LttngEvent;
import org.eclipse.linuxtools.lttng.event.LttngEventContent;
-import org.eclipse.linuxtools.lttng.event.LttngEventField;
-import org.eclipse.linuxtools.lttng.event.LttngEventFormat;
import org.eclipse.linuxtools.lttng.event.LttngEventReference;
+import org.eclipse.linuxtools.lttng.event.LttngEventSource;
import org.eclipse.linuxtools.lttng.event.LttngEventType;
import org.eclipse.linuxtools.lttng.event.LttngTimestamp;
import org.eclipse.linuxtools.lttng.jni.JniEvent;
+import org.eclipse.linuxtools.lttng.jni.JniMarker;
import org.eclipse.linuxtools.lttng.jni.JniTime;
import org.eclipse.linuxtools.lttng.jni.JniTrace;
-import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfEventSource;
+import org.eclipse.linuxtools.lttng.jni.JniTracefile;
import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.trace.TmfTrace;
* (seeking, reading and parsing) through the JNI component.
*/
public class LTTngTrace extends TmfTrace {
-
- private final static boolean IS_PARSING_NEEDED_DEFAULT = true;
- private final static int CHECKPOINT_PAGE_SIZE = 1000;
-
- // Reference to the current LttngEvent
- private LttngEvent currentLttngEvent = null;
+ private final static boolean SHOW_LTT_DEBUG_DEFAULT = false;
+ private final static boolean IS_PARSING_NEEDED_DEFAULT = false;
+ private final static int CHECKPOINT_PAGE_SIZE = 1;
// Reference to our JNI trace
private JniTrace currentJniTrace = null;
+ // *** HACK ***
+ // To save time, we will declare all component of the LttngEvent during the construction of the trace
+ // Then, while reading the trace, we will just SET the values instead of declaring new object
+ LttngTimestamp eventTimestamp = null;
+ LttngEventSource eventSource = null;
+ LttngEventType eventType = null;
+ LttngEventContent eventContent = null;
+ LttngEventReference eventReference = null;
+ // The actual event
+ LttngEvent currentLttngEvent = null;
+
+ // Hashmap of the possible types of events (Tracefile/CPU/Marker in the JNI)
+ HashMap<String, LttngEventType> traceTypes = null;
+ // This vector will be used to quickly find a marker name from a position
+ Vector<String> traceTypeNames = null;
+
/**
* Default Constructor.<p>
*
* @param path Path to a <b>directory</b> that contain an LTTng trace.
*
* @exception Exception (most likely LTTngTraceException or FileNotFoundException)
- *
- * @see org.eclipse.linuxtools.lttng.jni.JniTrace
*/
public LTTngTrace(String path) throws Exception {
// Call with "wait for completion" true and "skip indexing" false
* @param waitForCompletion Should we wait for indexign to complete before moving on.
*
* @exception Exception (most likely LTTngTraceException or FileNotFoundException)
- *
- * @see org.eclipse.linuxtools.lttng.jni.JniTrace
*/
public LTTngTrace(String path, boolean waitForCompletion) throws Exception {
- // Call with "skip indexing" false
+ // Call with "skip indexing" false
this(path, waitForCompletion, false);
}
*
* @exception Exception (most likely LTTngTraceException or FileNotFoundException)
*
- * @see org.eclipse.linuxtools.lttng.jni.JniTrace
*/
public LTTngTrace(String path, boolean waitForCompletion, boolean bypassIndexing) throws Exception {
super(path, CHECKPOINT_PAGE_SIZE, true);
try {
- currentJniTrace = new JniTrace(path);
+ currentJniTrace = new JniTrace(path, SHOW_LTT_DEBUG_DEFAULT);
}
catch (Exception e) {
throw new LTTngTraceException(e.getMessage());
}
- TmfTimestamp startTime = new LttngTimestamp(currentJniTrace.getStartTimeFromTimestampCurrentCounter().getTime());
+
+ // Set the start time of the trace
+ LttngTimestamp startTime = new LttngTimestamp(currentJniTrace.getStartTimeFromTimestampCurrentCounter().getTime());
setTimeRange(new TmfTimeRange(startTime, startTime));
+ // Export all the event types from the JNI side
+ traceTypes = new HashMap<String, LttngEventType>();
+ traceTypeNames = new Vector<String>();
+ initialiseEventTypes(currentJniTrace);
+
+ // *** VERIFY ***
+ // Verify that all those "default constructor" are safe to use
+ eventTimestamp = new LttngTimestamp();
+ eventSource = new LttngEventSource();
+ eventType = new LttngEventType();
+ eventContent = new LttngEventContent(currentLttngEvent);
+ eventReference = new LttngEventReference(this.getName());
+
+ // Create the skeleton event
+ currentLttngEvent = new LttngEvent(eventTimestamp, eventSource, eventType, eventContent, eventReference, null);
+
+ // Set the currentEvent to the eventContent
+ eventContent.setEvent(currentLttngEvent);
+
// Bypass indexing if asked
if ( bypassIndexing == false ) {
indexStream();
throw new Exception("Copy constructor should never be use with a LTTngTrace!");
}
+ /*
+ * Fill out the HashMap with "Type" (Tracefile/Marker)
+ *
+ * This should be called at construction once the trace is open
+ */
+ private void initialiseEventTypes(JniTrace trace) {
+ // Work variables
+ LttngEventType tmpType = null;
+ String[] markerFieldsLabels = null;
+
+ String newTracefileKey = null;
+ Integer newMarkerKey = null;
+
+ JniTracefile newTracefile = null;
+ JniMarker newMarker = null;
+
+ // First, obtain an iterator on TRACEFILES of owned by the TRACE
+ Iterator<String> tracefileItr = trace.getTracefilesMap().keySet().iterator();
+ while ( tracefileItr.hasNext() ) {
+ newTracefileKey = tracefileItr.next();
+ newTracefile = trace.getTracefilesMap().get(newTracefileKey);
+
+ // From the TRACEFILE read, obtain its MARKER
+ Iterator<Integer> markerItr = newTracefile.getTracefileMarkersMap().keySet().iterator();
+ while ( markerItr.hasNext() ) {
+ newMarkerKey = markerItr.next();
+ newMarker = newTracefile.getTracefileMarkersMap().get(newMarkerKey);
+
+ // From the MARKER we can obtain the MARKERFIELDS keys (i.e. labels)
+ markerFieldsLabels = newMarker.getMarkerFieldsHashMap().keySet().toArray( new String[newMarker.getMarkerFieldsHashMap().size()] );
+ tmpType = new LttngEventType(newTracefile.getTracefileName(), newTracefile.getCpuNumber(), newMarker.getName(), markerFieldsLabels );
+
+ // Add the type to the map/vector
+ addEventTypeToMap(tmpType);
+ }
+ }
+ }
+
+ /*
+ * Add a new type to the HashMap
+ *
+ * As the hashmap use a key format that is a bit dangerous to use, we should always add using this function.
+ */
+ private void addEventTypeToMap(LttngEventType newEventType) {
+ String newTypeKey = EventTypeKey.getEventTypeKey(newEventType);
+
+ this.traceTypes.put(newTypeKey, newEventType);
+ this.traceTypeNames.add(newTypeKey);
+ }
+
/**
- * Parse the next event in the trace.<p>
+ * Return the next event in the trace.<p>
*
* @param context The actual context of the trace
*
- * @return The parsed event, or null if none available
+ * @return The next event, or null if none available
*
- * @see org.eclipse.linuxtools.lttng.jni.JniTrace
+ * @see org.eclipse.linuxtools.lttng.event.LttngEvent
*/
@Override
- public TmfEvent parseEvent(TmfTraceContext context) {
+ public LttngEvent parseEvent(TmfTraceContext context) {
JniEvent jniEvent;
LttngTimestamp timestamp = null;
+ LttngEvent returnedEvent = null;
synchronized (currentJniTrace) {
// Seek to the context's location
// Read an event from the JNI and convert it into a LttngEvent
jniEvent = currentJniTrace.readNextEvent();
- currentLttngEvent = (jniEvent != null) ? convertJniEventToTmf(jniEvent, true) : null;
+
+ //currentLttngEvent = (jniEvent != null) ? convertJniEventToTmf(jniEvent, true) : null;
+ if ( jniEvent != null ) {
+ currentLttngEvent = convertJniEventToTmf(jniEvent);
+ returnedEvent = currentLttngEvent;
+ }
// Save timestamp
timestamp = (LttngTimestamp) getCurrentLocation();
context.setLocation(timestamp);
context.setTimestamp(timestamp);
context.incrIndex();
-
- return currentLttngEvent;
+
+ return returnedEvent;
}
/**
*
* @param newEvent The JniEvent to convert into LttngEvent
*
- * @return The converted event
+ * @return The converted LttngEvent
*
- * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+ * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
+ * @see org.eclipse.linuxtools.lttng.event.LttngEvent
*/
public LttngEvent convertJniEventToTmf(JniEvent newEvent) {
- LttngEvent event = null;
- if (newEvent != null)
- event = convertJniEventToTmf(newEvent, IS_PARSING_NEEDED_DEFAULT);
- return event;
+ currentLttngEvent = convertJniEventToTmf(newEvent, IS_PARSING_NEEDED_DEFAULT);
+
+ return currentLttngEvent;
}
/**
- * Method tp convert a JniEvent into a LttngEvent
+ * Method to convert a JniEvent into a LttngEvent
*
* @param jniEvent The JniEvent to convert into LttngEvent
* @param isParsingNeeded A boolean value telling if the event should be parsed or not.
*
- * @return The converted event
+ * @return The converted LttngEvent
*
- * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+ * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
+ * @see org.eclipse.linuxtools.lttng.event.LttngEvent
*/
public LttngEvent convertJniEventToTmf(JniEvent jniEvent, boolean isParsingNeeded) {
-
- // *** FIXME ***
- // Format seems weird to me... we need to revisit Format/Fields/Content to find a better ways
- //
- // Generate fields
- String[] labels = new String[jniEvent.requestEventMarker().getMarkerFieldsHashMap().size()];
- labels = jniEvent.requestEventMarker().getMarkerFieldsHashMap().keySet().toArray( labels );
-
- // We need a format for content and fields
- LttngEventFormat eventFormat = new LttngEventFormat(labels);
- String content = "";
- LttngEventField[] fields = null;
-
- if (isParsingNeeded == true) {
- fields = eventFormat.parse(jniEvent.parseAllFields());
- for (int y = 0; y < fields.length; y++) {
- content += fields[y].toString() + " ";
- }
- }
+ // *** HACK ***
+ // To save time here, we only set value instead of allocating new object
+ // This give an HUGE performance improvement
+ // all allocation done in the LttngTrace constructor
- LttngEvent event = null;
- try {
- event = new LttngEvent(
- new LttngTimestamp(jniEvent.getEventTime().getTime()),
- new TmfEventSource(jniEvent.requestEventSource() ),
- new LttngEventType(jniEvent.getParentTracefile().getTracefileName(),
- jniEvent.getParentTracefile().getCpuNumber(),
- jniEvent.requestEventMarker().getName(),
- eventFormat),
- new LttngEventContent(eventFormat, content, fields),
- new LttngEventReference(jniEvent.getParentTracefile().getTracefilePath(), this.getName()),
- jniEvent);
- }
- catch (LttngException e) {
- System.out.println("ERROR : Event creation returned :" + e.getMessage() );
+ eventTimestamp.setValue(jniEvent.getEventTime().getTime());
+ eventSource.setSourceId(jniEvent.requestEventSource());
+
+ eventType = traceTypes.get( EventTypeKey.getEventTypeKey(jniEvent) );
+
+ eventReference.setValue(jniEvent.getParentTracefile().getTracefilePath());
+ eventReference.setTracepath(this.getName());
+
+// eventContent.setEvent(currentLttngEvent);
+// eventContent.setType(eventType);
+ eventContent.emptyContent();
+
+// currentLttngEvent.setContent(eventContent);
+ currentLttngEvent.setType(eventType);
+ // Save the jni reference
+ currentLttngEvent.setJniEventReference(jniEvent);
+
+ // Parse now if was asked
+ // Warning : THIS IS SLOW
+ if (isParsingNeeded == true ) {
+ eventContent.getFields();
}
- return event;
+ return currentLttngEvent;
}
/**
*
* @return Reference to the current LttngTrace
*
- * @see org.eclipse.linuxtools.lttng.jni.JniTrace
+ * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniTrace
*/
public JniTrace getCurrentJniTrace() {
return currentJniTrace;
return returnedData;
}
+}
+
+/*
+ * EventTypeKey inner class
+ *
+ * This class is used to make the process of generating the HashMap key more transparent and so less error prone to use
+ *
+ */
+class EventTypeKey {
+ //*** WARNING ***
+ // These two getEventTypeKey() functions should ALWAYS construct the key the same ways!
+ // Otherwise, every type search will fail!
+
+ static public String getEventTypeKey(LttngEventType newEventType) {
+ String key = newEventType.getTracefileName() + "/" + newEventType.getCpuId().toString() + "/" + newEventType.getMarkerName();
+
+ return key;
+ }
-}
\ No newline at end of file
+ static public String getEventTypeKey(JniEvent newEvent) {
+ String key = newEvent.getParentTracefile().getTracefileName() + "/" + newEvent.getParentTracefile().getCpuNumber() + "/" + newEvent.requestEventMarker().getName();
+
+ return key;
+ }
+
+}
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: Test
+Bundle-Name: TMF Unit Test Suite
Bundle-SymbolicName: org.eclipse.linuxtools.tmf.tests
-Bundle-Version: 0.0.1
+Bundle-Version: 0.1.0.qualifier
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: Eclipse
-Require-Bundle: org.junit4;bundle-version="4.5.0",
+Require-Bundle: org.junit;bundle-version="3.8.2",
org.eclipse.linuxtools.tmf;bundle-version="0.0.1"
+++ /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.event;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TmfTimestampTest.class,
- TmfTimeRangeTest.class,
- TmfEventTypeTest.class,
- TmfEventFormatTest.class,
- TmfEventContentTest.class,
- TmfEventTest.class,
- TmfTraceEventTest.class
-})
-
-public class AllEventTests {
-
-}
--- /dev/null
+package org.eclipse.linuxtools.tmf.event;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AllTests.class.getName());
+ //$JUnit-BEGIN$
+ suite.addTestSuite(TmfEventFieldTest.class);
+ suite.addTestSuite(TmfEventContentTest.class);
+ suite.addTestSuite(TmfEventTypeTest.class);
+ suite.addTestSuite(TmfEventSourceTest.class);
+ suite.addTestSuite(TmfTraceEventTest.class);
+ suite.addTestSuite(TmfEventReferenceTest.class);
+ suite.addTestSuite(TmfTimestampTest.class);
+ suite.addTestSuite(TmfTimeRangeTest.class);
+ suite.addTestSuite(TmfEventTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
package org.eclipse.linuxtools.tmf.event;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
+import junit.framework.TestCase;
/**
* <b><u>TmfEventContentTest</u></b>
* <p>
- * JUnit test suite for the TmfEventContent class.
+ * TODO: Implement me. Please.
*/
-public class TmfEventContentTest {
+public class TmfEventContentTest extends TestCase {
+
+ private final TmfTimestamp fTimestamp;
+ private final TmfEventSource fEventSource;
+ private final TmfEventType fEventType;
+ private final TmfEventTypeStub fEventTypeStub;
+ private final TmfEventReference fReference;
+ private final TmfEvent fEvent;
+ private final TmfEvent fEventStub;
+
+ private final Object fRawContent = new String("Some content");
+
+ private final TmfEventContent fBasicContent;
+ private final TmfEventContentStub fStubContent;
+
+ /**
+ * @param name
+ */
+ public TmfEventContentTest(String name) {
+ super(name);
+ fTimestamp = new TmfTimestamp();
+ fEventSource = new TmfEventSource();
+ fEventType = new TmfEventType();
+ fEventTypeStub = new TmfEventTypeStub();
+ fReference = new TmfEventReference();
+
+ fEvent = new TmfEvent(fTimestamp, fEventSource, fEventType, fReference);
+ fBasicContent = new TmfEventContent(fEvent, fRawContent);
+
+ fEventStub = new TmfEvent(fTimestamp, fEventSource, fEventTypeStub, fReference);
+ fStubContent = new TmfEventContentStub(fEventStub, fRawContent);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
// ========================================================================
// Constructors
// ========================================================================
- @Test
public void testTmfEventContent() {
- TmfEventContent content = new TmfEventContent("Some content", new TmfEventFormat());
- assertEquals("getFormat", 1, content.getFormat().getLabels().length);
- assertEquals("getLabels", "Content", content.getFormat().getLabels()[0]);
- assertEquals("getContent", "Some content", content.getContent());
+ assertSame("getLabels", fEvent, fBasicContent.getEvent());
+ assertSame("getType", fEventType, fBasicContent.getType());
+ assertSame("getContent", fRawContent, fBasicContent.getContent());
+ }
+
+ public void testTmfEventContentCopy() {
+ TmfEventContent content = new TmfEventContent(fBasicContent);
+ assertSame("getLabels", fEvent, content.getEvent());
+ assertSame("getType", fEventType, content.getType());
+ assertSame("getContent", fRawContent, content.getContent());
+ }
+
+ public void testCloneShallowCopy() {
+ TmfEventContent content = fBasicContent.clone();
+ assertSame("getLabels", fEvent, content.getEvent());
+ assertSame("getType", fEventType, content.getType());
+ assertSame("getContent", fRawContent, content.getContent());
+ }
+
+ public void testCloneDeepCopy() {
+ TmfEventContent content = fStubContent.clone();
+ assertSame ("getEvent", fEventStub, content.getEvent());
+ assertSame ("getType", fEventTypeStub, content.getType());
+ assertNotSame("getContent", fRawContent, content.getContent());
+ assertEquals ("getContent", fRawContent, content.getContent());
+ }
+
+ // ========================================================================
+ // Basic content parsing
+ // ========================================================================
+
+ public void testGetFields() {
+ Object[] fields = fBasicContent.getFields();
+ assertEquals("getFields", 1, fields.length);
+ assertEquals("getFields", fRawContent, fields[0].toString());
+ }
+
+ public void testGetFieldFromId() {
+ Object field;
+ try {
+ field = fBasicContent.getField("Content");
+ assertEquals("getField", fRawContent, field.toString());
+ } catch (TmfNoSuchFieldException e) {
+ fail("Field not found");
+ }
+ }
+
+ public void testGetFieldFromIdFailed() {
+ try {
+ fBasicContent.getField("Dummy");
+ fail("Found an inexisting field...");
+ } catch (TmfNoSuchFieldException e) {
+ // Success
+ }
+ }
+
+ public void testGetFieldFromPos() {
+ Object field = fBasicContent.getField(0);
+ assertEquals("getField", fRawContent, field.toString());
}
// ========================================================================
- // getField
+ // Standard content parsing
// ========================================================================
- @Test
- public void testBasicGetField() {
- TmfEventContent content = new TmfEventContent("Some content", new TmfEventFormat());
- assertEquals("getField", 1, content.getFields().length);
- assertEquals("getField", "Some content", content.getField(0).toString());
+ public void testGetFields2() {
+ Object[] fields = fStubContent.getFields();
+ assertEquals("getFields", 5, fields.length);
}
- @Test
- public void testExtendedGetField() {
- TmfEventContent content = new TmfEventContent("", new TmfEventFormatStub());
- assertEquals("getField", 5, content.getFields().length);
- assertEquals("getField", "1", content.getField(0).toString());
- assertEquals("getField", "-10", content.getField(1).toString());
- assertEquals("getField", "true", content.getField(2).toString());
- assertEquals("getField", "some string", content.getField(3).toString());
- assertEquals("getField", "[TmfTimestamp:1,2,3]", content.getField(4).toString());
+ public void testGetFieldFromId2() {
+ Object field;
+ try {
+ field = fStubContent.getField("Field1");
+ assertEquals("getField", new Integer(1), field);
+
+ field = fStubContent.getField("Field2");
+ assertEquals("getField", new Integer(-10), field);
+
+ field = fStubContent.getField("Field3");
+ assertEquals("getField", new Boolean(true), field);
+
+ field = fStubContent.getField("Field4");
+ assertEquals("getField", new String("some string"), field);
+
+ field = fStubContent.getField("Field5");
+ assertEquals("getField", new TmfTimestamp(1, (byte) 2, 3), field);
+
+ } catch (TmfNoSuchFieldException e) {
+ fail("Field not found");
+ }
+ }
+
+ public void testGetFieldFromPos2() {
+ TmfEventContentStub content = new TmfEventContentStub(fEvent, fRawContent);
+
+ Object field = content.getField(0);
+ assertEquals("getField", new Integer(1), field);
+
+ field = content.getField(1);
+ assertEquals("getField", new Integer(-10), field);
+
+ field = content.getField(2);
+ assertEquals("getField", new Boolean(true), field);
+
+ field = content.getField(3);
+ assertEquals("getField", new String("some string"), field);
+
+ field = content.getField(4);
+ assertEquals("getField", new TmfTimestamp(1, (byte) 2, 3), field);
+ }
+
+ // ========================================================================
+ // Operators
+ // ========================================================================
+
+ public void testToString() {
+ String expected = "[TmfEventContent(" + fRawContent + ",)]";
+ TmfEventContent content = new TmfEventContent(fEvent, fRawContent);
+ assertEquals("toString", expected, content.toString());
}
}
--- /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.event;
+
+import junit.framework.TestCase;
+
+/**
+ * <b><u>TmfEventFieldTest</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+public class TmfEventFieldTest extends TestCase {
+
+ private final TmfEventContent fContent;
+ private final String fFieldId = "Field";
+ private final Object fValue1 = new String("Value");
+ private final Object fValue2 = new Integer(10);
+
+ // ========================================================================
+ // Housekeeping
+ // ========================================================================
+
+ public TmfEventFieldTest(String name) {
+ super(name);
+ TmfTimestamp fTimestamp = new TmfTimestamp();
+ TmfEventSource fEventSource = new TmfEventSource();
+ TmfEventType fEventType = new TmfEventTypeStub();
+ TmfEventReference fReference = new TmfEventReference();
+ TmfEvent fEvent = new TmfEvent(fTimestamp, fEventSource, fEventType, fReference);
+
+ fContent = new TmfEventContent(fEvent, "Some content");
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ // ========================================================================
+ // Constructors
+ // ========================================================================
+
+ public void testTmfEventField() {
+ TmfEventField field = new TmfEventField(fContent, fFieldId, fValue1);
+ assertSame("getParent", fContent, field.getParent());
+ assertSame("getId", fFieldId, field.getId());
+ assertSame("getValue", fValue1, field.getValue());
+ }
+
+ public void testTmfEventFieldCopy() {
+ TmfEventField original = new TmfEventField(fContent, fFieldId, fValue1);
+ TmfEventField field = new TmfEventField(original);
+ assertSame("getParent", fContent, field.getParent());
+ assertSame("getId", fFieldId, field.getId());
+ assertSame("getValue", fValue1, field.getValue());
+ }
+
+ public void testCloneShallowCopy() {
+ TmfEventField original = new TmfEventField(fContent, fFieldId, fValue1);
+ TmfEventField field = original.clone();
+ assertSame("getParent", fContent, field.getParent());
+ assertSame("getId", fFieldId, field.getId());
+ assertSame("getValue", fValue1, field.getValue());
+ }
+
+// public void testCloneDeepCopy() {
+// TmfEventField original = new TmfEventField(fContent, fFieldId, fValue1);
+// TmfEventField field = original.clone();
+// assertNotSame("getParent", fContent, field.getParent());
+// assertNotSame("getId", fFieldId, field.getId());
+// assertNotSame("getValue", fValue1, field.getValue());
+// assertEquals ("getParent", fContent, field.getParent());
+// assertEquals ("getId", fFieldId, field.getId());
+// assertEquals ("getValue", fValue1, field.getValue());
+// }
+
+ // ========================================================================
+ // Operators
+ // ========================================================================
+
+ public void testToString() {
+ String expected1 = "[TmfEventField(" + fFieldId + ":" + fValue1.toString() + ")]";
+ TmfEventField field = new TmfEventField(fContent, fFieldId, fValue1);
+ assertEquals("toString", expected1, field.toString());
+
+ String expected2 = "[TmfEventField(" + fFieldId + ":" + fValue2.toString() + ")]";
+ field = new TmfEventField(fContent, fFieldId, fValue2);
+ assertEquals("toString", expected2, field.toString());
+ }
+
+}
+++ /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.event;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-/**
- * <b><u>TmfEventFormatTest</u></b>
- * <p>
- * JUnit test suite for the TmfEventFormat class.
- */
-public class TmfEventFormatTest {
-
- // ========================================================================
- // Constructors
- // ========================================================================
-
- @Test
- public void testBasicTmfEventFormat() {
- TmfEventFormat format = new TmfEventFormat();
- assertEquals("getLabels", 1, format.getLabels().length);
- assertEquals("getValue", "Content", format.getLabels()[0]);
- }
-
- @Test
- public void testEmptyConstructor() {
- TmfEventFormat format = new TmfEventFormat(new String[] {});
- assertEquals("getLabels", 0, format.getLabels().length);
- }
-
- @Test
- public void testNormalConstructor() {
- TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2", "field3" });
- assertEquals("getLabels", 3, format.getLabels().length);
- assertEquals("getLabels", "field1", format.getLabels()[0]);
- assertEquals("getLabels", "field2", format.getLabels()[1]);
- assertEquals("getLabels", "field3", format.getLabels()[2]);
- }
-
- @Test
- public void testExtendedConstructor() {
- TmfEventFormatStub format = new TmfEventFormatStub();
- assertEquals("getLabels", 5, format.getLabels().length);
- assertEquals("getLabels", "Field1", format.getLabels()[0]);
- assertEquals("getLabels", "Field2", format.getLabels()[1]);
- assertEquals("getLabels", "Field3", format.getLabels()[2]);
- assertEquals("getLabels", "Field4", format.getLabels()[3]);
- assertEquals("getLabels", "Field5", format.getLabels()[4]);
- }
-
- // ========================================================================
- // parse
- // ========================================================================
-
- @Test
- public void testBasicParse() {
- TmfEventFormat format = new TmfEventFormat();
- TmfEventField[] content = format.parse(new TmfTimestamp());
- assertEquals("length", 1, content.length);
- assertEquals("getValue", "[TmfTimestamp:0,0,0]", content[0].toString());
- }
-
- @Test
- public void testExtendedParse() {
- TmfEventFormatStub format = new TmfEventFormatStub();
- TmfEventField[] content = format.parse(new TmfTimestamp());
- assertEquals("length", 5, content.length);
- assertEquals("getValue", "1", content[0].toString());
- assertEquals("getValue", "-10", content[1].toString());
- assertEquals("getValue", "true", content[2].toString());
- assertEquals("getValue", "some string", content[3].toString());
- assertEquals("getValue", "[TmfTimestamp:1,2,3]", content[4].toString());
- }
-
-}
--- /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.event;
+
+import junit.framework.TestCase;
+
+/**
+ * <b><u>TmfEventReferenceTest</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+public class TmfEventReferenceTest extends TestCase {
+
+ private final Object fReference = new String("Some reference");
+
+ // ========================================================================
+ // Housekeeping
+ // ========================================================================
+
+ public TmfEventReferenceTest(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ // ========================================================================
+ // Constructors
+ // ========================================================================
+
+ public void testTmfEventReferenceDefault() {
+ TmfEventReference reference = new TmfEventReference();
+ assertEquals("getReference", null, reference.getReference());
+ }
+
+ public void testTmfEventReference() {
+ TmfEventReference reference = new TmfEventReference(fReference);
+ assertSame("getReference", fReference, reference.getReference());
+ }
+
+ public void testTmfEventReferenceCopy() {
+ TmfEventReference original = new TmfEventReference(fReference);
+ TmfEventReference reference = new TmfEventReference(original);
+ assertSame("getReference", fReference, reference.getReference());
+ }
+
+ public void testCloneShallowCopy() {
+ TmfEventReference original = new TmfEventReference(fReference);
+ TmfEventReference reference = original.clone();
+ assertSame("getReference", fReference, reference.getReference());
+ }
+
+// public void testCloneDeepCopy() {
+// TmfEventReference original = new TmfEventReference(fReference);
+// TmfEventReference reference = original.clone();
+// assertNotSame("getReference", fReference, reference.getReference());
+// assertEquals ("getReference", fReference, reference.getReference());
+// }
+
+ // ========================================================================
+ // Operators
+ // ========================================================================
+
+ public void testToString() {
+ String expected1 = "[TmfEventReference(" + "null" + ")]";
+ TmfEventReference reference1 = new TmfEventReference();
+ assertEquals("toString", expected1, reference1.toString());
+
+ String expected2 = "[TmfEventReference(" + fReference.toString() + ")]";
+ TmfEventReference reference2 = new TmfEventReference(fReference);
+ assertEquals("toString", expected2, reference2.toString());
+ }
+
+}
--- /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.event;
+
+import junit.framework.TestCase;
+
+/**
+ * <b><u>TmfEventSourceTest</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+public class TmfEventSourceTest extends TestCase {
+
+ private final Object fSource = new String("Some source");
+
+ // ========================================================================
+ // Housekeeping
+ // ========================================================================
+
+ public TmfEventSourceTest(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ // ========================================================================
+ // Constructors
+ // ========================================================================
+
+ public void testTmfEventSourceDefault() {
+ TmfEventSource source = new TmfEventSource();
+ assertEquals("getSourceId", null, source.getSourceId());
+ }
+
+ public void testTmfEventSource() {
+ TmfEventSource source = new TmfEventSource(fSource);
+ assertSame("getSourceId", fSource, source.getSourceId());
+ }
+
+ public void testTmfEventSourceCopy() {
+ TmfEventSource original = new TmfEventSource(fSource);
+ TmfEventSource source = new TmfEventSource(original);
+ assertSame("getSourceId", fSource, source.getSourceId());
+ }
+
+ public void testCloneShallowCopy() {
+ TmfEventSource original = new TmfEventSource(fSource);
+ TmfEventSource source = original.clone();
+ assertSame("getSourceId", fSource, source.getSourceId());
+ }
+
+// public void testCloneDeepCopy() {
+// TmfEventSource original = new TmfEventSource(fSource);
+// TmfEventSource source = original.clone();
+// assertNotSame("getSourceId", fSource, source.getSourceId());
+// assertEquals ("getSourceId", fSource, source.getSourceId());
+// }
+
+ // ========================================================================
+ // Operators
+ // ========================================================================
+
+ public void testToString() {
+ String expected1 = "[TmfEventSource(" + "null" + ")]";
+ TmfEventSource source1 = new TmfEventSource();
+ assertEquals("toString", expected1, source1.toString());
+
+ String expected2 = "[TmfEventSource(" + fSource.toString() + ")]";
+ TmfEventSource source2 = new TmfEventSource(fSource);
+ assertEquals("toString", expected2, source2.toString());
+ }
+
+}
package org.eclipse.linuxtools.tmf.event;
-import static org.junit.Assert.*;
-
-import org.junit.Test;
+import junit.framework.TestCase;
/**
* <b><u>TmfEventTest</u></b>
* <p>
- * JUNit test suite for the TmfEvent class.
+ * TODO: Implement me. Please.
*/
-public class TmfEventTest {
-
- // ========================================================================
- // Constructor
- // ========================================================================
-
- @Test
- public void testTmfEvent() {
- TmfTimestamp timestamp = new TmfTimestamp(12345, (byte) 2, 5);
- TmfEventSource source = new TmfEventSource("Source");
- TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2" });
- TmfEventType type = new TmfEventType("Type", format);
- TmfEventContent content = new TmfEventContent("Some content", format);
- TmfEventReference reference = new TmfEventReference("Reference");
-
- // Create the event
- TmfEvent event = new TmfEvent(timestamp, source, type, content, reference);
-
- // Check the event timestamp
- TmfTimestamp ts = event.getTimestamp();
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", 2, ts.getScale());
- assertEquals("getPrecision", 5, ts.getPrecision());
-
- // Check the original event timestamp
- ts = event.getOriginalTimestamp();
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", 2, ts.getScale());
- assertEquals("getPrecision", 5, ts.getPrecision());
-
- // Check the event source
- TmfEventSource src = event.getSource();
- assertEquals("getValue", "Source", src.getSourceId());
-
- // Check the event type
- TmfEventType tp = event.getType();
- assertEquals("getValue", "Type", tp.getTypeId());
- assertEquals("getFormat", "field1", tp.getFormat().getLabels()[0]);
- assertEquals("getFormat", "field2", tp.getFormat().getLabels()[1]);
-
- // Check the event content
- TmfEventContent cnt = event.getContent();
- assertEquals("getField", 1, cnt.getFields().length);
- assertEquals("getField", "Some content", cnt.getField(0).toString());
-
- // Check the event reference
- TmfEventReference ref = event.getReference();
- assertEquals("getValue", "Reference", ref.getValue());
- }
-
- @Test
- public void testTmfEvent2() {
- TmfTimestamp original = new TmfTimestamp(12345, (byte) 2, 5);
- TmfTimestamp effective = new TmfTimestamp(12350, (byte) 2, 5);
- TmfEventSource source = new TmfEventSource("Source");
- TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2" });
- TmfEventType type = new TmfEventType("Type", format);
- TmfEventContent content = new TmfEventContent("Some content", format);
- TmfEventReference reference = new TmfEventReference("Reference");
-
- // Create the event
- TmfEvent event = new TmfEvent(original, effective, source, type, content, reference);
-
- // Check the event timestamp
- TmfTimestamp ts = event.getTimestamp();
- assertEquals("getValue", 12350, ts.getValue());
- assertEquals("getscale", 2, ts.getScale());
- assertEquals("getPrecision", 5, ts.getPrecision());
-
- // Check the original event timestamp
- ts = event.getOriginalTimestamp();
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", 2, ts.getScale());
- assertEquals("getPrecision", 5, ts.getPrecision());
-
- // Check the event source
- TmfEventSource src = event.getSource();
- assertEquals("getValue", "Source", src.getSourceId());
-
- // Check the event type
- TmfEventType tp = event.getType();
- assertEquals("getValue", "Type", tp.getTypeId());
- assertEquals("getFormat", "field1", tp.getFormat().getLabels()[0]);
- assertEquals("getFormat", "field2", tp.getFormat().getLabels()[1]);
-
- // Check the event content
- TmfEventContent cnt = event.getContent();
- assertEquals("getField", 1, cnt.getFields().length);
- assertEquals("getField", "Some content", cnt.getField(0).toString());
-
- // Check the event reference
- TmfEventReference ref = event.getReference();
- assertEquals("getValue", "Reference", ref.getValue());
- }
+public class TmfEventTest extends TestCase {
+
+ private final String fTypeId = "Some type";
+ private final String fLabel0 = "label1";
+ private final String fLabel1 = "label2";
+ private final String[] fLabels = new String[] { fLabel0, fLabel1 };
+
+ private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2, 5);
+ private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2, 5);
+ private final TmfEventSource fSource = new TmfEventSource("Source");
+ private final TmfEventType fType = new TmfEventType(fTypeId, fLabels);
+ private final TmfEventReference fReference = new TmfEventReference("Some reference");
+
+ private final TmfEvent fEvent1;
+ private final TmfEvent fEvent2;
+
+ private final TmfEventContent fContent1;
+ private final TmfEventContent fContent2;
+
+ // ========================================================================
+ // Housekeeping
+ // ========================================================================
+
+ public TmfEventTest(String name) {
+ super(name);
+
+ fEvent1 = new TmfEvent(fTimestamp1, fSource, fType, fReference);
+ fContent1 = new TmfEventContent(fEvent1, "Some content");
+ fEvent1.setContent(fContent1);
+
+ fEvent2 = new TmfEvent(fTimestamp1, fTimestamp2, fSource, fType, fReference);
+ fContent2 = new TmfEventContent(fEvent2, "Some other content");
+ fEvent2.setContent(fContent2);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ // ========================================================================
+ // Constructors
+ // ========================================================================
+
+ public void testTmfEvent() {
+ assertEquals("getTimestamp", fTimestamp1, fEvent1.getTimestamp());
+ assertEquals("getOriginalTimestamp", fTimestamp1, fEvent1.getOriginalTimestamp());
+ assertEquals("getSource", fSource, fEvent1.getSource());
+ assertEquals("getType", fType, fEvent1.getType());
+ assertEquals("getContent", fContent1, fEvent1.getContent());
+ assertEquals("getReference", fReference, fEvent1.getReference());
+ }
+
+ public void testTmfEvent2() {
+ assertEquals("getTimestamp", fTimestamp2, fEvent2.getTimestamp());
+ assertEquals("getOriginalTimestamp", fTimestamp1, fEvent2.getOriginalTimestamp());
+ assertEquals("getSource", fSource, fEvent2.getSource());
+ assertEquals("getType", fType, fEvent2.getType());
+ assertEquals("getContent", fContent2, fEvent2.getContent());
+ assertEquals("getReference", fReference, fEvent2.getReference());
+ }
+
+ public void testTmfEventCopy() {
+ TmfEvent event = new TmfEvent(fEvent1);
+ assertEquals("getTimestamp", fTimestamp1, event.getTimestamp());
+ assertEquals("getOriginalTimestamp", fTimestamp1, event.getOriginalTimestamp());
+ assertEquals("getSource", fSource, event.getSource());
+ assertEquals("getType", fType, event.getType());
+ assertEquals("getContent", fContent1, event.getContent());
+ assertEquals("getReference", fReference, event.getReference());
+ }
+
+// public void testTmfEventCloneShallowCopy() {
+// TmfEvent event = fEvent1.clone();
+// assertEquals("getTimestamp", fTimestamp1, event.getTimestamp());
+// assertEquals("getOriginalTimestamp", fTimestamp1, event.getOriginalTimestamp());
+// assertEquals("getSource", fSource, event.getSource());
+// assertEquals("getType", fType, event.getType());
+// assertEquals("getContent", fContent1, event.getContent());
+// assertEquals("getReference", fReference, event.getReference());
+// }
+
+// public void testTmfEventCloneDeepCopy() {
+// TmfEvent event = fEvent1.clone();
+// assertEquals("getTimestamp", fTimestamp1, event.getTimestamp());
+// assertEquals("getOriginalTimestamp", fTimestamp1, event.getOriginalTimestamp());
+// assertEquals("getSource", fSource, event.getSource());
+// assertEquals("getType", fType, event.getType());
+// assertEquals("getContent", fContent1, event.getContent());
+// assertEquals("getReference", fReference, event.getReference());
+// }
+
+ // ========================================================================
+ // Operators
+ // ========================================================================
+
+// public void testToString() {
+// String expected1 = "[TmfEventType:" + TmfEventType.DEFAULT_TYPE_ID + "]";
+// assertEquals("toString", expected1, fEvent1.toString());
+//
+// String expected2 = "[TmfEventType:" + fTypeId + "]";
+// assertEquals("toString", expected2, fEvent2.toString());
+// }
}
package org.eclipse.linuxtools.tmf.event;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
+import junit.framework.TestCase;
/**
* <b><u>TmfEventTypeTest</u></b>
* <p>
* JUnit test suite for the TmfEventType class.
*/
-public class TmfEventTypeTest {
-
- // ========================================================================
- // Constructor
- // ========================================================================
-
- @Test
- public void testEmptyConstructor() {
- TmfEventType type = new TmfEventType("", null);
- assertEquals("getValue", "", type.getTypeId());
- assertEquals("getFormat", null, type.getFormat());
- }
-
- @Test
- public void testNormalConstructor() {
- TmfEventType type = new TmfEventType("Type", new TmfEventFormat(new String[] { "field1", "field2" }));
- assertEquals("getValue", "Type", type.getTypeId());
- assertEquals("getFormat", "field1", type.getFormat().getLabels()[0]);
- assertEquals("getFormat", "field2", type.getFormat().getLabels()[1]);
- }
+public class TmfEventTypeTest extends TestCase {
+
+ private final String fTypeId = "Some type";
+ private final String fLabel0 = "label1";
+ private final String fLabel1 = "label2";
+ private final String[] fLabels = new String[] { fLabel0, fLabel1 };
+
+ // ========================================================================
+ // Housekeeping
+ // ========================================================================
+
+ public TmfEventTypeTest(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ // ========================================================================
+ // Constructors
+ // ========================================================================
+
+ public void testTmfEventTypeDefault() {
+ TmfEventType type = new TmfEventType();
+ try {
+ assertEquals("getTypeId", TmfEventType.DEFAULT_TYPE_ID, type.getTypeId());
+ assertEquals("getNbFields", 1, type.getNbFields());
+ assertEquals("getFieldIndex", 0, type.getFieldIndex(TmfEventType.DEFAULT_LABELS[0]));
+ assertEquals("getLabels", TmfEventType.DEFAULT_LABELS, type.getLabels());
+ assertEquals("getLabel", TmfEventType.DEFAULT_LABELS[0], type.getLabel(0));
+ } catch (TmfNoSuchFieldException e) {
+ fail("getFieldIndex: no such field");
+ }
+ }
+
+ public void testTmfEventType() {
+ TmfEventType type = new TmfEventType(fTypeId, fLabels);
+ try {
+ assertEquals("getTypeId", fTypeId, type.getTypeId());
+ assertEquals("getNbFields", fLabels.length, type.getNbFields());
+ assertEquals("getFieldIndex", 0, type.getFieldIndex(fLabel0));
+ assertEquals("getFieldIndex", 1, type.getFieldIndex(fLabel1));
+ assertEquals("getLabels", fLabels, type.getLabels());
+ assertEquals("getLabel", fLabel0, type.getLabel(0));
+ assertEquals("getLabel", fLabel1, type.getLabel(1));
+ } catch (TmfNoSuchFieldException e) {
+ fail("getFieldIndex: no such field");
+ }
+
+ try {
+ assertEquals("getFieldIndex", 0, type.getFieldIndex("Dummy"));
+ fail("getFieldIndex: inexistant field");
+ } catch (TmfNoSuchFieldException e) {
+ // Success
+ }
+ }
+
+ public void testTmfEventTypeCopy() {
+ TmfEventType original = new TmfEventType(fTypeId, fLabels);
+ TmfEventType type = new TmfEventType(original);
+ assertEquals("getTypeId", fTypeId, type.getTypeId());
+ assertEquals("getNbFields", fLabels.length, type.getNbFields());
+ assertEquals("getLabels", fLabels, type.getLabels());
+ }
+
+ public void testCloneShallowCopy() {
+ TmfEventType original = new TmfEventType(fTypeId, fLabels);
+ TmfEventType type = original.clone();
+ assertEquals("getTypeId", fTypeId, type.getTypeId());
+ assertEquals("getNbFields", fLabels.length, type.getNbFields());
+ assertEquals("getLabels", fLabels, type.getLabels());
+ }
+
+// public void testCloneDeepCopy() {
+// fail("Not yet implemented");
+// }
+
+ // ========================================================================
+ // Operators
+ // ========================================================================
+
+ public void testToString() {
+ String expected1 = "[TmfEventType:" + TmfEventType.DEFAULT_TYPE_ID + "]";
+ TmfEventType type1 = new TmfEventType();
+ assertEquals("toString", expected1, type1.toString());
+
+ String expected2 = "[TmfEventType:" + fTypeId + "]";
+ TmfEventType type2 = new TmfEventType(fTypeId, fLabels);
+ assertEquals("toString", expected2, type2.toString());
+ }
}
package org.eclipse.linuxtools.tmf.event;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-
-import org.junit.Test;
+import junit.framework.TestCase;
/**
* <b><u>TmfTimeRangeTest</u></b>
* <p>
- * JUnit test suite for the TmfTimeRange class.
+ * TODO: Implement me. Please.
*/
-public class TmfTimeRangeTest {
-
- // ========================================================================
- // Constructors
- // ========================================================================
-
- @Test
- public void testConstructor() throws Exception {
- TmfTimestamp ts1 = new TmfTimestamp(12345);
- TmfTimestamp ts2 = new TmfTimestamp(12350);
- TmfTimeRange range = new TmfTimeRange(ts1, ts2);
- assertEquals("startTime", ts1, range.getStartTime());
- assertEquals("endTime", ts2, range.getEndTime());
- }
-
- @Test
- public void testOpenRange1() throws Exception {
- TmfTimestamp ts2 = new TmfTimestamp(12350);
- TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, ts2);
- assertEquals("startTime", TmfTimestamp.BigBang, range.getStartTime());
- assertEquals("endTime", ts2, range.getEndTime());
- }
-
- @Test
- public void testOpenRange2() throws Exception {
- TmfTimestamp ts1 = new TmfTimestamp(12345);
- TmfTimeRange range = new TmfTimeRange(ts1, TmfTimestamp.BigCrunch);
- assertEquals("startTime", ts1, range.getStartTime());
- assertEquals("endTime", TmfTimestamp.BigCrunch, range.getEndTime());
- }
-
- @Test
- public void testOpenRange3() throws Exception {
- TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- assertEquals("startTime", TmfTimestamp.BigBang, range.getStartTime());
- assertEquals("endTime", TmfTimestamp.BigCrunch, range.getEndTime());
- }
-
- // ========================================================================
- // Constructors
- // ========================================================================
-
- @Test
- public void testContains() throws Exception {
- TmfTimestamp ts1 = new TmfTimestamp(12345);
- TmfTimestamp ts2 = new TmfTimestamp(12350);
- TmfTimeRange range = new TmfTimeRange(ts1, ts2);
-
- assertTrue("contains (lower bound)", range.contains(new TmfTimestamp(12345)));
- assertTrue("contains (higher bound)", range.contains(new TmfTimestamp(12350)));
- assertTrue("contains (within bounds)", range.contains(new TmfTimestamp(12346)));
-
- assertFalse("contains (low value)", range.contains(new TmfTimestamp(12340)));
- assertFalse("contains (high value)", range.contains(new TmfTimestamp(12351)));
- }
+public class TmfTimeRangeTest extends TestCase {
+
+ // ========================================================================
+ // Housekeeping
+ // ========================================================================
+
+ public TmfTimeRangeTest(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ // ========================================================================
+ // Constructors
+ // ========================================================================
+
+ public void testConstructor() throws Exception {
+ TmfTimestamp ts1 = new TmfTimestamp(12345);
+ TmfTimestamp ts2 = new TmfTimestamp(12350);
+ TmfTimeRange range = new TmfTimeRange(ts1, ts2);
+ assertEquals("startTime", ts1, range.getStartTime());
+ assertEquals("endTime", ts2, range.getEndTime());
+ }
+
+ public void testOpenRange1() throws Exception {
+ TmfTimestamp ts2 = new TmfTimestamp(12350);
+ TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, ts2);
+ assertEquals("startTime", TmfTimestamp.BigBang, range.getStartTime());
+ assertEquals("endTime", ts2, range.getEndTime());
+ }
+
+ public void testOpenRange2() throws Exception {
+ TmfTimestamp ts1 = new TmfTimestamp(12345);
+ TmfTimeRange range = new TmfTimeRange(ts1, TmfTimestamp.BigCrunch);
+ assertEquals("startTime", ts1, range.getStartTime());
+ assertEquals("endTime", TmfTimestamp.BigCrunch, range.getEndTime());
+ }
+
+ public void testOpenRange3() throws Exception {
+ TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+ assertEquals("startTime", TmfTimestamp.BigBang, range.getStartTime());
+ assertEquals("endTime", TmfTimestamp.BigCrunch, range.getEndTime());
+ }
+
+ // ========================================================================
+ // contains
+ // ========================================================================
+
+ public void testContains() throws Exception {
+ TmfTimestamp ts1 = new TmfTimestamp(12345);
+ TmfTimestamp ts2 = new TmfTimestamp(12350);
+ TmfTimeRange range = new TmfTimeRange(ts1, ts2);
+
+ assertTrue("contains (lower bound)", range.contains(new TmfTimestamp(12345)));
+ assertTrue("contains (higher bound)", range.contains(new TmfTimestamp(12350)));
+ assertTrue("contains (within bounds)", range.contains(new TmfTimestamp(12346)));
+
+ assertFalse("contains (low value)", range.contains(new TmfTimestamp(12340)));
+ assertFalse("contains (high value)", range.contains(new TmfTimestamp(12351)));
+ }
+
+ // ========================================================================
+ // toString
+ // ========================================================================
+
+ public void testToString() throws Exception {
+ TmfTimestamp ts1 = new TmfTimestamp(12345);
+ TmfTimestamp ts2 = new TmfTimestamp(12350);
+ TmfTimeRange range = new TmfTimeRange(ts1, ts2);
+ String expected = "[TmfTimeRange(" + ts1.toString() + ":" + ts2.toString() + ")]";
+ assertEquals("toString", expected, range.toString());
+ }
+
}
package org.eclipse.linuxtools.tmf.event;
-import static org.junit.Assert.*;
-
-import org.junit.Test;
+import junit.framework.TestCase;
/**
* <b><u>TmfTimestampTest</u></b>
* <p>
- * JUnit test suite for the TmfTimestamp class.
+ * TODO: Implement me. Please.
*/
-public class TmfTimestampTest {
-
- // ========================================================================
- // Constructors
- // ========================================================================
-
- @Test
- public void testDefaultConstructor() throws Exception {
- TmfTimestamp ts = new TmfTimestamp();
- assertEquals("getValue", 0, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
- }
-
- @Test
- public void testSimpleConstructor() throws Exception {
- TmfTimestamp ts = new TmfTimestamp(12345);
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
- }
-
- @Test
- public void testSimpleConstructor2() throws Exception {
- TmfTimestamp ts = new TmfTimestamp(12345, (byte) -1);
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", -1, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
- }
-
- @Test
- public void testFullConstructor() throws Exception {
- TmfTimestamp ts = new TmfTimestamp(12345, (byte) 2, 5);
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", 2, ts.getScale());
- assertEquals("getPrecision", 5, ts.getPrecision());
- }
-
- @Test
- public void testCopyConstructor() throws Exception {
- TmfTimestamp ts0 = new TmfTimestamp(12345, (byte) 2, 5);
- TmfTimestamp ts = new TmfTimestamp(ts0);
- assertEquals("getValue", 12345, ts.getValue());
- assertEquals("getscale", 2, ts.getScale());
- assertEquals("getPrecision", 5, ts.getPrecision());
- }
-
- // ========================================================================
- // BigBang, BigCrunch
- // ========================================================================
-
- @Test
- public void testCopyConstructorBigBang() throws Exception {
- TmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BigBang);
- assertEquals("getValue", TmfTimestamp.BigBang.getValue(), ts.getValue());
- assertEquals("getscale", TmfTimestamp.BigBang.getScale(), ts.getScale());
- assertEquals("getPrecision", TmfTimestamp.BigBang.getPrecision(), ts.getPrecision());
- }
-
- @Test
- public void testCopyConstructorBigCrunch() throws Exception {
- TmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BigCrunch);
- assertEquals("getValue", TmfTimestamp.BigCrunch.getValue(), ts.getValue());
- assertEquals("getscale", TmfTimestamp.BigCrunch.getScale(), ts.getScale());
- assertEquals("getPrecision", TmfTimestamp.BigCrunch.getPrecision(), ts.getPrecision());
- }
-
- // ========================================================================
- // toString
- // ========================================================================
-
- @Test
- public void testToString() throws Exception {
- TmfTimestamp ts1 = new TmfTimestamp();
- TmfTimestamp ts2 = new TmfTimestamp(1234, (byte) 2);
- TmfTimestamp ts3 = new TmfTimestamp(1234, (byte) 2, 1);
- TmfTimestamp ts4 = new TmfTimestamp(-1234, (byte) -1, 4);
-
- assertEquals("toString", "[TmfTimestamp:0,0,0]", ts1.toString());
- assertEquals("toString", "[TmfTimestamp:1234,2,0]", ts2.toString());
- assertEquals("toString", "[TmfTimestamp:1234,2,1]", ts3.toString());
- assertEquals("toString", "[TmfTimestamp:-1234,-1,4]", ts4.toString());
- }
-
- // ========================================================================
- // synchronize
- // ========================================================================
-
- @Test
- public void testSynchronizeOffset() throws Exception {
- TmfTimestamp ts0 = new TmfTimestamp(1234, (byte) 0, 1);
- TmfTimestamp ts = new TmfTimestamp();
-
- ts = ts0.synchronize(0, (byte) 0);
- assertEquals("getValue", 1234, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 1, ts.getPrecision());
-
- ts = ts0.synchronize(10, (byte) 0);
- assertEquals("getValue", 1244, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 1, ts.getPrecision());
-
- ts = ts0.synchronize(-10, (byte) 0);
- assertEquals("getValue", 1224, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 1, ts.getPrecision());
- }
-
- @Test
- public void testSynchronizeScale() throws Exception {
- TmfTimestamp ts0 = new TmfTimestamp(1234, (byte) 0, 12);
- TmfTimestamp ts = new TmfTimestamp();
-
- ts = ts0.synchronize(0, (byte) 0);
- assertEquals("getValue", 1234, ts.getValue());
- assertEquals("getscale", 0, ts.getScale());
- assertEquals("getPrecision", 12, ts.getPrecision());
-
- ts = ts0.synchronize(0, (byte) 1);
- assertEquals("getValue", 123, ts.getValue());
- assertEquals("getscale", 1, ts.getScale());
- assertEquals("getPrecision", 1, ts.getPrecision());
-
- ts = ts0.synchronize(0, (byte) 2);
- assertEquals("getValue", 12, ts.getValue());
- assertEquals("getscale", 2, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.synchronize(0, (byte) 4);
- assertEquals("getValue", 0, ts.getValue());
- assertEquals("getscale", 4, ts.getScale());
- assertEquals("getPrecision", 0, ts.getPrecision());
-
- ts = ts0.synchronize(0, (byte) -2);
- assertEquals("getValue", 123400, ts.getValue());
- assertEquals("getscale", -2, ts.getScale());
- assertEquals("getPrecision", 1200, ts.getPrecision());
- }
-
- @Test
- public void testSynchronizeOffsetAndScale() throws Exception {
- TmfTimestamp ts0 = new TmfTimestamp(1234, (byte) 0, 12);
- TmfTimestamp ts = new TmfTimestamp();
-
- ts = ts0.synchronize(10, (byte) 1);
- assertEquals("getValue", 133, ts.getValue());
- assertEquals("getscale", 1, ts.getScale());
- assertEquals("getPrecision", 1, ts.getPrecision());
-
- ts = ts0.synchronize(-10, (byte) -1);
- assertEquals("getValue", 12330, ts.getValue());
- assertEquals("getscale", -1, ts.getScale());
- assertEquals("getPrecision", 120, ts.getPrecision());
- }
-
- // ========================================================================
- // getAdjustment
- // ========================================================================
-
- @Test
- public void testGetAdjustmentSameScale() throws Exception {
- TmfTimestamp ts0 = new TmfTimestamp(12345, (byte) -2);
- TmfTimestamp ts = new TmfTimestamp(10000, (byte) -2);
-
- long delta = ts.getAdjustment(ts0);
- assertEquals("delta", 2345, delta);
- }
-
- @Test
- public void testGetAdjustmentDifferentScale() throws Exception {
- TmfTimestamp ts0 = new TmfTimestamp(12345, (byte) -2);
- TmfTimestamp ts = new TmfTimestamp( 1, (byte) 2);
-
- long delta = ts.getAdjustment(ts0);
- assertEquals("delta", 2345, delta);
-
- delta = ts0.getAdjustment(ts);
- assertEquals("delta", 0, delta);
- }
-
- // ========================================================================
- // CompareTo
- // ========================================================================
-
- @Test
- public void testCompareToSameScale() throws Exception {
- TmfTimestamp ts1 = new TmfTimestamp( 900, (byte) 0, 50);
- TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
- TmfTimestamp ts3 = new TmfTimestamp(1100, (byte) 0, 50);
- TmfTimestamp ts4 = new TmfTimestamp(1000, (byte) 0, 75);
-
- assertTrue(ts1.compareTo(ts1, false) == 0);
-
- assertTrue(ts1.compareTo(ts2, false) < 0);
- assertTrue(ts1.compareTo(ts3, false) < 0);
- assertTrue(ts1.compareTo(ts4, false) < 0);
-
- assertTrue(ts2.compareTo(ts1, false) > 0);
- assertTrue(ts2.compareTo(ts3, false) < 0);
- assertTrue(ts2.compareTo(ts4, false) == 0);
-
- assertTrue(ts3.compareTo(ts1, false) > 0);
- assertTrue(ts3.compareTo(ts2, false) > 0);
- assertTrue(ts3.compareTo(ts4, false) > 0);
- }
-
- @Test
- public void testCompareToDifferentScale() throws Exception {
- TmfTimestamp ts1 = new TmfTimestamp(9000, (byte) -1, 50);
- TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
- TmfTimestamp ts3 = new TmfTimestamp( 110, (byte) 1, 50);
- TmfTimestamp ts4 = new TmfTimestamp( 1, (byte) 3, 75);
-
- assertTrue(ts1.compareTo(ts1, false) == 0);
-
- assertTrue(ts1.compareTo(ts2, false) < 0);
- assertTrue(ts1.compareTo(ts3, false) < 0);
- assertTrue(ts1.compareTo(ts4, false) < 0);
-
- assertTrue(ts2.compareTo(ts1, false) > 0);
- assertTrue(ts2.compareTo(ts3, false) < 0);
- assertTrue(ts2.compareTo(ts4, false) == 0);
-
- assertTrue(ts3.compareTo(ts1, false) > 0);
- assertTrue(ts3.compareTo(ts2, false) > 0);
- assertTrue(ts3.compareTo(ts4, false) > 0);
- }
-
- @Test
- public void testCompareToWithinPrecision() throws Exception {
- TmfTimestamp ts1 = new TmfTimestamp( 900, (byte) 0, 50);
- TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
- TmfTimestamp ts3 = new TmfTimestamp(1100, (byte) 0, 50);
- TmfTimestamp ts4 = new TmfTimestamp(1000, (byte) 0, 75);
-
- assertTrue(ts1.compareTo(ts1, true) == 0);
-
- assertTrue(ts1.compareTo(ts2, true) == 0);
- assertTrue(ts1.compareTo(ts3, true) < 0);
- assertTrue(ts1.compareTo(ts4, true) == 0);
-
- assertTrue(ts2.compareTo(ts1, true) == 0);
- assertTrue(ts2.compareTo(ts3, true) == 0);
- assertTrue(ts2.compareTo(ts4, true) == 0);
-
- assertTrue(ts3.compareTo(ts1, true) > 0);
- assertTrue(ts3.compareTo(ts2, true) == 0);
- assertTrue(ts3.compareTo(ts4, true) == 0);
- }
-
- @Test
- public void testCompareToLargeScale() throws Exception {
- TmfTimestamp ts1 = new TmfTimestamp( -1, (byte) 100);
- TmfTimestamp ts2 = new TmfTimestamp(-1000, (byte) -100);
- TmfTimestamp ts3 = new TmfTimestamp( 1, (byte) 100);
- TmfTimestamp ts4 = new TmfTimestamp( 1000, (byte) -100);
-
- assertTrue(ts1.compareTo(ts2, false) < 0);
- assertTrue(ts1.compareTo(ts3, false) < 0);
- assertTrue(ts1.compareTo(ts4, false) < 0);
-
- assertTrue(ts2.compareTo(ts1, false) > 0);
- assertTrue(ts2.compareTo(ts3, false) < 0);
- assertTrue(ts2.compareTo(ts4, false) < 0);
-
- assertTrue(ts3.compareTo(ts1, false) > 0);
- assertTrue(ts3.compareTo(ts2, false) > 0);
- assertTrue(ts3.compareTo(ts4, false) > 0);
-
- assertTrue(ts4.compareTo(ts1, false) > 0);
- assertTrue(ts4.compareTo(ts2, false) > 0);
- assertTrue(ts4.compareTo(ts3, false) < 0);
- }
-
- @Test
- public void testCompareToBigGuys() throws Exception {
- TmfTimestamp ts1 = new TmfTimestamp(-1, Byte.MAX_VALUE);
- TmfTimestamp ts2 = new TmfTimestamp(-1, Byte.MIN_VALUE);
- TmfTimestamp ts3 = new TmfTimestamp( 1, Byte.MAX_VALUE);
- TmfTimestamp ts4 = new TmfTimestamp( 1, Byte.MIN_VALUE);
-
- assertTrue(ts1.compareTo(TmfTimestamp.BigBang, false) > 0);
- assertTrue(ts1.compareTo(TmfTimestamp.BigCrunch, false) < 0);
-
- assertTrue(ts2.compareTo(TmfTimestamp.BigBang, false) > 0);
- assertTrue(ts2.compareTo(TmfTimestamp.BigCrunch, false) < 0);
-
- assertTrue(ts3.compareTo(TmfTimestamp.BigBang, false) > 0);
- assertTrue(ts3.compareTo(TmfTimestamp.BigCrunch, false) < 0);
-
- assertTrue(ts4.compareTo(TmfTimestamp.BigBang, false) > 0);
- assertTrue(ts4.compareTo(TmfTimestamp.BigCrunch, false) < 0);
- }
+public class TmfTimestampTest extends TestCase {
+
+ // ========================================================================
+ // Housekeeping
+ // ========================================================================
+
+ public TmfTimestampTest(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ // ========================================================================
+ // Constructors
+ // ========================================================================
+
+ public void testDefaultConstructor() throws Exception {
+ TmfTimestamp ts = new TmfTimestamp();
+ assertEquals("getValue", 0, ts.getValue());
+ assertEquals("getscale", 0, ts.getScale());
+ assertEquals("getPrecision", 0, ts.getPrecision());
+ }
+
+ public void testSimpleConstructor() throws Exception {
+ TmfTimestamp ts = new TmfTimestamp(12345);
+ assertEquals("getValue", 12345, ts.getValue());
+ assertEquals("getscale", 0, ts.getScale());
+ assertEquals("getPrecision", 0, ts.getPrecision());
+ }
+
+ public void testSimpleConstructor2() throws Exception {
+ TmfTimestamp ts = new TmfTimestamp(12345, (byte) -1);
+ assertEquals("getValue", 12345, ts.getValue());
+ assertEquals("getscale", -1, ts.getScale());
+ assertEquals("getPrecision", 0, ts.getPrecision());
+ }
+
+ public void testFullConstructor() throws Exception {
+ TmfTimestamp ts = new TmfTimestamp(12345, (byte) 2, 5);
+ assertEquals("getValue", 12345, ts.getValue());
+ assertEquals("getscale", 2, ts.getScale());
+ assertEquals("getPrecision", 5, ts.getPrecision());
+ }
+
+ public void testCopyConstructor() throws Exception {
+ TmfTimestamp ts0 = new TmfTimestamp(12345, (byte) 2, 5);
+ TmfTimestamp ts = new TmfTimestamp(ts0);
+ assertEquals("getValue", 12345, ts.getValue());
+ assertEquals("getscale", 2, ts.getScale());
+ assertEquals("getPrecision", 5, ts.getPrecision());
+ }
+
+ // ========================================================================
+ // BigBang, BigCrunch
+ // ========================================================================
+
+ public void testCopyConstructorBigBang() throws Exception {
+ TmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BigBang);
+ assertEquals("getValue", TmfTimestamp.BigBang.getValue(), ts.getValue());
+ assertEquals("getscale", TmfTimestamp.BigBang.getScale(), ts.getScale());
+ assertEquals("getPrecision", TmfTimestamp.BigBang.getPrecision(), ts.getPrecision());
+ }
+
+ public void testCopyConstructorBigCrunch() throws Exception {
+ TmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BigCrunch);
+ assertEquals("getValue", TmfTimestamp.BigCrunch.getValue(), ts.getValue());
+ assertEquals("getscale", TmfTimestamp.BigCrunch.getScale(), ts.getScale());
+ assertEquals("getPrecision", TmfTimestamp.BigCrunch.getPrecision(), ts.getPrecision());
+ }
+
+ // ========================================================================
+ // toString
+ // ========================================================================
+
+ public void testToString() throws Exception {
+ TmfTimestamp ts1 = new TmfTimestamp();
+ TmfTimestamp ts2 = new TmfTimestamp(1234, (byte) 2);
+ TmfTimestamp ts3 = new TmfTimestamp(1234, (byte) 2, 1);
+ TmfTimestamp ts4 = new TmfTimestamp(-1234, (byte) -1, 4);
+
+ assertEquals("toString", "[TmfTimestamp(0,0,0)]", ts1.toString());
+ assertEquals("toString", "[TmfTimestamp(1234,2,0)]", ts2.toString());
+ assertEquals("toString", "[TmfTimestamp(1234,2,1)]", ts3.toString());
+ assertEquals("toString", "[TmfTimestamp(-1234,-1,4)]", ts4.toString());
+ }
+
+ // ========================================================================
+ // synchronize
+ // ========================================================================
+
+ public void testSynchronizeOffset() throws Exception {
+ TmfTimestamp ts0 = new TmfTimestamp(1234, (byte) 0, 1);
+ TmfTimestamp ts = new TmfTimestamp();
+
+ ts = ts0.synchronize(0, (byte) 0);
+ assertEquals("getValue", 1234, ts.getValue());
+ assertEquals("getscale", 0, ts.getScale());
+ assertEquals("getPrecision", 1, ts.getPrecision());
+
+ ts = ts0.synchronize(10, (byte) 0);
+ assertEquals("getValue", 1244, ts.getValue());
+ assertEquals("getscale", 0, ts.getScale());
+ assertEquals("getPrecision", 1, ts.getPrecision());
+
+ ts = ts0.synchronize(-10, (byte) 0);
+ assertEquals("getValue", 1224, ts.getValue());
+ assertEquals("getscale", 0, ts.getScale());
+ assertEquals("getPrecision", 1, ts.getPrecision());
+ }
+
+ public void testSynchronizeScale() throws Exception {
+ TmfTimestamp ts0 = new TmfTimestamp(1234, (byte) 0, 12);
+ TmfTimestamp ts = new TmfTimestamp();
+
+ ts = ts0.synchronize(0, (byte) 0);
+ assertEquals("getValue", 1234, ts.getValue());
+ assertEquals("getscale", 0, ts.getScale());
+ assertEquals("getPrecision", 12, ts.getPrecision());
+
+ ts = ts0.synchronize(0, (byte) 1);
+ assertEquals("getValue", 123, ts.getValue());
+ assertEquals("getscale", 1, ts.getScale());
+ assertEquals("getPrecision", 1, ts.getPrecision());
+
+ ts = ts0.synchronize(0, (byte) 2);
+ assertEquals("getValue", 12, ts.getValue());
+ assertEquals("getscale", 2, ts.getScale());
+ assertEquals("getPrecision", 0, ts.getPrecision());
+
+ ts = ts0.synchronize(0, (byte) 4);
+ assertEquals("getValue", 0, ts.getValue());
+ assertEquals("getscale", 4, ts.getScale());
+ assertEquals("getPrecision", 0, ts.getPrecision());
+
+ ts = ts0.synchronize(0, (byte) -2);
+ assertEquals("getValue", 123400, ts.getValue());
+ assertEquals("getscale", -2, ts.getScale());
+ assertEquals("getPrecision", 1200, ts.getPrecision());
+ }
+
+ public void testSynchronizeOffsetAndScale() throws Exception {
+ TmfTimestamp ts0 = new TmfTimestamp(1234, (byte) 0, 12);
+ TmfTimestamp ts = new TmfTimestamp();
+
+ ts = ts0.synchronize(10, (byte) 1);
+ assertEquals("getValue", 133, ts.getValue());
+ assertEquals("getscale", 1, ts.getScale());
+ assertEquals("getPrecision", 1, ts.getPrecision());
+
+ ts = ts0.synchronize(-10, (byte) -1);
+ assertEquals("getValue", 12330, ts.getValue());
+ assertEquals("getscale", -1, ts.getScale());
+ assertEquals("getPrecision", 120, ts.getPrecision());
+ }
+
+ // ========================================================================
+ // getAdjustment
+ // ========================================================================
+
+ public void testGetAdjustmentSameScale() throws Exception {
+ TmfTimestamp ts0 = new TmfTimestamp(12345, (byte) -2);
+ TmfTimestamp ts = new TmfTimestamp(10000, (byte) -2);
+
+ long delta = ts.getAdjustment(ts0);
+ assertEquals("delta", 2345, delta);
+ }
+
+ public void testGetAdjustmentDifferentScale() throws Exception {
+ TmfTimestamp ts0 = new TmfTimestamp(12345, (byte) -2);
+ TmfTimestamp ts = new TmfTimestamp(1, (byte) 2);
+
+ long delta = ts.getAdjustment(ts0);
+ assertEquals("delta", 2345, delta);
+
+ delta = ts0.getAdjustment(ts);
+ assertEquals("delta", 0, delta);
+ }
+
+ // ========================================================================
+ // CompareTo
+ // ========================================================================
+
+ public void testCompareToSameScale() throws Exception {
+ TmfTimestamp ts1 = new TmfTimestamp(900, (byte) 0, 50);
+ TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
+ TmfTimestamp ts3 = new TmfTimestamp(1100, (byte) 0, 50);
+ TmfTimestamp ts4 = new TmfTimestamp(1000, (byte) 0, 75);
+
+ assertTrue(ts1.compareTo(ts1, false) == 0);
+
+ assertTrue(ts1.compareTo(ts2, false) < 0);
+ assertTrue(ts1.compareTo(ts3, false) < 0);
+ assertTrue(ts1.compareTo(ts4, false) < 0);
+
+ assertTrue(ts2.compareTo(ts1, false) > 0);
+ assertTrue(ts2.compareTo(ts3, false) < 0);
+ assertTrue(ts2.compareTo(ts4, false) == 0);
+
+ assertTrue(ts3.compareTo(ts1, false) > 0);
+ assertTrue(ts3.compareTo(ts2, false) > 0);
+ assertTrue(ts3.compareTo(ts4, false) > 0);
+ }
+
+ public void testCompareToDifferentScale() throws Exception {
+ TmfTimestamp ts1 = new TmfTimestamp(9000, (byte) -1, 50);
+ TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
+ TmfTimestamp ts3 = new TmfTimestamp(110, (byte) 1, 50);
+ TmfTimestamp ts4 = new TmfTimestamp(1, (byte) 3, 75);
+
+ assertTrue(ts1.compareTo(ts1, false) == 0);
+
+ assertTrue(ts1.compareTo(ts2, false) < 0);
+ assertTrue(ts1.compareTo(ts3, false) < 0);
+ assertTrue(ts1.compareTo(ts4, false) < 0);
+
+ assertTrue(ts2.compareTo(ts1, false) > 0);
+ assertTrue(ts2.compareTo(ts3, false) < 0);
+ assertTrue(ts2.compareTo(ts4, false) == 0);
+
+ assertTrue(ts3.compareTo(ts1, false) > 0);
+ assertTrue(ts3.compareTo(ts2, false) > 0);
+ assertTrue(ts3.compareTo(ts4, false) > 0);
+ }
+
+ public void testCompareToWithinPrecision() throws Exception {
+ TmfTimestamp ts1 = new TmfTimestamp(900, (byte) 0, 50);
+ TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
+ TmfTimestamp ts3 = new TmfTimestamp(1100, (byte) 0, 50);
+ TmfTimestamp ts4 = new TmfTimestamp(1000, (byte) 0, 75);
+
+ assertTrue(ts1.compareTo(ts1, true) == 0);
+
+ assertTrue(ts1.compareTo(ts2, true) == 0);
+ assertTrue(ts1.compareTo(ts3, true) < 0);
+ assertTrue(ts1.compareTo(ts4, true) == 0);
+
+ assertTrue(ts2.compareTo(ts1, true) == 0);
+ assertTrue(ts2.compareTo(ts3, true) == 0);
+ assertTrue(ts2.compareTo(ts4, true) == 0);
+
+ assertTrue(ts3.compareTo(ts1, true) > 0);
+ assertTrue(ts3.compareTo(ts2, true) == 0);
+ assertTrue(ts3.compareTo(ts4, true) == 0);
+ }
+
+ public void testCompareToLargeScale() throws Exception {
+ TmfTimestamp ts1 = new TmfTimestamp(-1, (byte) 100);
+ TmfTimestamp ts2 = new TmfTimestamp(-1000, (byte) -100);
+ TmfTimestamp ts3 = new TmfTimestamp(1, (byte) 100);
+ TmfTimestamp ts4 = new TmfTimestamp(1000, (byte) -100);
+
+ assertTrue(ts1.compareTo(ts2, false) < 0);
+ assertTrue(ts1.compareTo(ts3, false) < 0);
+ assertTrue(ts1.compareTo(ts4, false) < 0);
+
+ assertTrue(ts2.compareTo(ts1, false) > 0);
+ assertTrue(ts2.compareTo(ts3, false) < 0);
+ assertTrue(ts2.compareTo(ts4, false) < 0);
+
+ assertTrue(ts3.compareTo(ts1, false) > 0);
+ assertTrue(ts3.compareTo(ts2, false) > 0);
+ assertTrue(ts3.compareTo(ts4, false) > 0);
+
+ assertTrue(ts4.compareTo(ts1, false) > 0);
+ assertTrue(ts4.compareTo(ts2, false) > 0);
+ assertTrue(ts4.compareTo(ts3, false) < 0);
+ }
+
+ public void testCompareToBigGuys() throws Exception {
+ TmfTimestamp ts1 = new TmfTimestamp(-1, Byte.MAX_VALUE);
+ TmfTimestamp ts2 = new TmfTimestamp(-1, Byte.MIN_VALUE);
+ TmfTimestamp ts3 = new TmfTimestamp(1, Byte.MAX_VALUE);
+ TmfTimestamp ts4 = new TmfTimestamp(1, Byte.MIN_VALUE);
+
+ assertTrue(ts1.compareTo(TmfTimestamp.BigBang, false) > 0);
+ assertTrue(ts1.compareTo(TmfTimestamp.BigCrunch, false) < 0);
+
+ assertTrue(ts2.compareTo(TmfTimestamp.BigBang, false) > 0);
+ assertTrue(ts2.compareTo(TmfTimestamp.BigCrunch, false) < 0);
+
+ assertTrue(ts3.compareTo(TmfTimestamp.BigBang, false) > 0);
+ assertTrue(ts3.compareTo(TmfTimestamp.BigCrunch, false) < 0);
+
+ assertTrue(ts4.compareTo(TmfTimestamp.BigBang, false) > 0);
+ assertTrue(ts4.compareTo(TmfTimestamp.BigCrunch, false) < 0);
+ }
}
package org.eclipse.linuxtools.tmf.event;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
+import junit.framework.TestCase;
/**
* <b><u>TmfTraceEventTest</u></b>
* <p>
- * JUnit test suite for the TmfTraceEvent class.
+ * TODO: Implement me. Please.
*/
-public class TmfTraceEventTest {
+public class TmfTraceEventTest extends TestCase {
+
+ private final String fTypeId = "Some type";
+ private final String fLabel0 = "label1";
+ private final String fLabel1 = "label2";
+ private final String[] fLabels = new String[] { fLabel0, fLabel1 };
+
+ private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2, 5);
+ private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2, 5);
+ private final TmfEventSource fSource = new TmfEventSource("Source");
+ private final TmfEventType fType = new TmfEventType(fTypeId, fLabels);
+ private final TmfEventReference fReference = new TmfEventReference("Some reference");
+
+ private final TmfTraceEvent fEvent1;
+ private final TmfTraceEvent fEvent2;
+
+ private final TmfEventContent fContent1;
+ private final TmfEventContent fContent2;
+
+ private final String fPath = "/some/path/";
+ private final String fFile = "filename";
+ private final int fLine = 10;
+
+ // ========================================================================
+ // Housekeeping
+ // ========================================================================
+
+ public TmfTraceEventTest(String name) {
+ super(name);
+
+ fEvent1 = new TmfTraceEvent(fTimestamp1, fSource, fType, fReference, fPath, fFile, fLine);
+ fContent1 = new TmfEventContent(fEvent1, "Some content");
+ fEvent1.setContent(fContent1);
- // ========================================================================
- // Constructor
- // ========================================================================
+ fEvent2 = new TmfTraceEvent(fTimestamp1, fTimestamp2, fSource, fType, fReference, fPath, fFile, fLine);
+ fContent2 = new TmfEventContent(fEvent2, "Some other content");
+ fEvent2.setContent(fContent2);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ // ========================================================================
+ // Constructors
+ // ========================================================================
- @Test
public void testTmfTraceEvent() throws Exception {
- TmfTimestamp timestamp = new TmfTimestamp(12345, (byte) 2, 5);
- TmfEventSource source = new TmfEventSource("Source");
- TmfEventFormat format = new TmfEventFormat(new String[] { "field1", "field2" });
- TmfEventType type = new TmfEventType("Type", format);
- TmfEventContent content = new TmfEventContent("Some content", format);
- TmfEventReference reference = new TmfEventReference("Reference");
-
- // Create the trace event
- TmfTraceEvent event =
- new TmfTraceEvent(timestamp, source, type, content, reference, "path", "filename", 10);
-
- // Check the event timestamp
- TmfTimestamp evTS = event.getTimestamp();
- assertEquals("getValue", 12345, evTS.getValue());
- assertEquals("getscale", 2, evTS.getScale());
- assertEquals("getPrecision", 5, evTS.getPrecision());
-
- // Check the event source
- TmfEventSource evSrc = event.getSource();
- assertEquals("getValue", "Source", evSrc.getSourceId());
-
- // Check the event type
- TmfEventType evType = event.getType();
- assertEquals("getValue", "Type", evType.getTypeId());
- assertEquals("getFormat", "field1", evType.getFormat().getLabels()[0]);
- assertEquals("getFormat", "field2", evType.getFormat().getLabels()[1]);
-
- // Check the event content
- TmfEventContent evContent = event.getContent();
- assertEquals("getField", 1, evContent.getFields().length);
- assertEquals("getField", "Some content", evContent.getField(0).toString());
-
- // Check the event reference
- TmfEventReference evRef = event.getReference();
- assertEquals("getValue", "Reference", evRef.getValue());
-
- // Check the event file reference
- assertEquals("getPath", "path", event.getSourcePath());
- assertEquals("getFile", "filename", event.getFileName());
- assertEquals("getLineNumber", 10, event.getLineNumber());
+ assertEquals("getTimestamp", fTimestamp1, fEvent1.getTimestamp());
+ assertEquals("getOriginalTimestamp", fTimestamp1, fEvent1.getOriginalTimestamp());
+ assertEquals("getSource", fSource, fEvent1.getSource());
+ assertEquals("getType", fType, fEvent1.getType());
+ assertEquals("getContent", fContent1, fEvent1.getContent());
+ assertEquals("getReference", fReference, fEvent1.getReference());
+ assertEquals("getSourcePath", fPath, fEvent1.getSourcePath());
+ assertEquals("getFileName", fFile, fEvent1.getFileName());
+ assertEquals("getLineNumber", fLine, fEvent1.getLineNumber());
+ }
+
+ public void testTmfTraceEvent2() throws Exception {
+ assertEquals("getTimestamp", fTimestamp2, fEvent2.getTimestamp());
+ assertEquals("getOriginalTimestamp", fTimestamp1, fEvent2.getOriginalTimestamp());
+ assertEquals("getSource", fSource, fEvent2.getSource());
+ assertEquals("getType", fType, fEvent2.getType());
+ assertEquals("getContent", fContent2, fEvent2.getContent());
+ assertEquals("getReference", fReference, fEvent2.getReference());
+ assertEquals("getSourcePath", fPath, fEvent2.getSourcePath());
+ assertEquals("getFileName", fFile, fEvent2.getFileName());
+ assertEquals("getLineNumber", fLine, fEvent2.getLineNumber());
+ }
+
+ public void testTmfTraceEventCopy() throws Exception {
+ TmfTraceEvent event = new TmfTraceEvent(fEvent2);
+ assertEquals("getTimestamp", fTimestamp2, event.getTimestamp());
+ assertEquals("getOriginalTimestamp", fTimestamp1, event.getOriginalTimestamp());
+ assertEquals("getSource", fSource, event.getSource());
+ assertEquals("getType", fType, event.getType());
+ assertEquals("getContent", fContent2, event.getContent());
+ assertEquals("getReference", fReference, event.getReference());
+ assertEquals("getSourcePath", fPath, event.getSourcePath());
+ assertEquals("getFileName", fFile, event.getFileName());
+ assertEquals("getLineNumber", fLine, event.getLineNumber());
}
}
+
+++ /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.request;
-
-import org.eclipse.linuxtools.tmf.request.TmfDataRequestTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TmfDataRequestTest.class,
-})
-
-public class AllRequestTests {
-
-}
--- /dev/null
+package org.eclipse.linuxtools.tmf.request;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AllTests.class.getName());
+ //$JUnit-BEGIN$
+ suite.addTestSuite(TmfDataRequestTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
package org.eclipse.linuxtools.tmf.request;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Vector;
+import junit.framework.TestCase;
import org.eclipse.linuxtools.tmf.event.TmfEvent;
import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.request.ITmfRequestHandler;
-import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
-import org.junit.BeforeClass;
-import org.junit.Test;
/**
* <b><u>TmfDataRequestTest</u></b>
* <p>
* TODO: Implement me. Please.
*/
-public class TmfDataRequestTest {
+public class TmfDataRequestTest extends TestCase {
- private static ITmfRequestHandler<TmfEvent> fProcessor = null;
+ // ========================================================================
+ // Housekeeping
+ // ========================================================================
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- fProcessor = new TmfRequestHandlerStub();
- }
+ public TmfDataRequestTest(String name) {
+ super(name);
+ }
- // ========================================================================
- // Constructor
- // ========================================================================
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
- @Test
- public void testConstructorForRange() throws Exception {
- TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, -1, 1);
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
- assertEquals("StartTime", TmfTimestamp.BigBang, request.getRange().getStartTime());
- assertEquals("EndTime", TmfTimestamp.BigCrunch, request.getRange().getEndTime());
- assertEquals("Offset", 0, request.getOffset());
- assertEquals("NbRequestedEvents", -1, request.getNbRequestedItems());
- }
+ // ========================================================================
+ // Constructors
+ // ========================================================================
- @Test
- public void testConstructorForNbEvents() throws Exception {
- TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, 10, 1);
+ public void testTmfDataRequestIndexNbEvents() {
+ TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(10, 100);
- assertEquals("StartTime", TmfTimestamp.BigBang, request.getRange().getStartTime());
- assertEquals("EndTime", TmfTimestamp.BigCrunch, request.getRange().getEndTime());
- assertEquals("Offset", 0, request.getOffset());
- assertEquals("NbRequestedEvents", 10, request.getNbRequestedItems());
- }
+ assertEquals("getRange", null, request.getRange());
+ assertEquals("getIndex", 10, request.getIndex());
+ assertEquals("getNbRequestedEvents", 100, request.getNbRequestedEvents());
+ assertEquals("getBlockize", TmfDataRequest.DEFAULT_BLOCK_SIZE, request.getBlockize());
+ }
- @Test
- public void testConstructorWithOffset() throws Exception {
- TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 5, 10, 1);
+ public void testTmfDataRequestIndexNbEventsBlocksize() {
+ TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(10, 100, 200);
- assertEquals("StartTime", TmfTimestamp.BigBang, request.getRange().getStartTime());
- assertEquals("EndTime", TmfTimestamp.BigCrunch, request.getRange().getEndTime());
- assertEquals("Offset", 5, request.getOffset());
- assertEquals("NbRequestedEvents", 10, request.getNbRequestedItems());
- }
+ assertEquals("getRange", null, request.getRange());
+ assertEquals("getIndex", 10, request.getIndex());
+ assertEquals("getNbRequestedEvents", 100, request.getNbRequestedEvents());
+ assertEquals("getBlockize", 200, request.getBlockize());
+ }
- @Test
- public void testConstructorWithNegativeOffset() throws Exception {
+ public void testTmfDataRequestTimeRange() {
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, -5, 10, 1);
+ TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range);
assertEquals("StartTime", TmfTimestamp.BigBang, request.getRange().getStartTime());
assertEquals("EndTime", TmfTimestamp.BigCrunch, request.getRange().getEndTime());
- assertEquals("Offset", -5, request.getOffset());
- assertEquals("NbRequestedEvents", 10, request.getNbRequestedItems());
- }
-
- // ========================================================================
- // process
- // ========================================================================
-
- @Test
- public void testProcessRequestForNbEvents() throws Exception {
-
- final int NB_EVENTS = 10 * 1000;
- final int BLOCK_SIZE = 100;
- final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+ assertEquals("getIndex", 0, request.getIndex());
+ assertEquals("getNbRequestedEvents", -1, request.getNbRequestedEvents());
+ assertEquals("getBlockize", TmfDataRequest.DEFAULT_BLOCK_SIZE, request.getBlockize());
+ }
+ public void testTmfDataRequestTimeRangeNbEvents() {
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
- @Override
- public void handleData() {
- TmfEvent[] events = getData();
- for (TmfEvent e : events) {
- requestedEvents.add(e);
- }
- }
- };
- fProcessor.processRequest(request, true);
-
- 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());
- }
- }
-
- @Test
- public void testProcessRequestForAllEvents() throws Exception {
-
- final int NB_EVENTS = -1;
- final int BLOCK_SIZE = 1;
- final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
- int nbExpectedEvents = TmfRequestHandlerStub.MAX_GENERATED_EVENTS;
+ TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 10);
- TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
- @Override
- public void handleData() {
- TmfEvent[] events = getData();
- for (TmfEvent e : events) {
- requestedEvents.add(e);
- }
- }
- };
- fProcessor.processRequest(request, true);
-
- assertEquals("nbEvents", nbExpectedEvents, 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 < nbExpectedEvents; i++) {
- assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
- }
- }
-
- // @Test
- public void testProcessRequestWithOffset() throws Exception {
-
- final int NB_EVENTS = -1;
- final int BLOCK_SIZE = 1;
- final int OFFSET = 5;
- final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
- int nbExpectedEvents = TmfRequestHandlerStub.MAX_GENERATED_EVENTS;
-
- TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
- @Override
- public void handleData() {
- TmfEvent[] events = getData();
- for (TmfEvent e : events) {
- requestedEvents.add(e);
- }
- }
- };
- fProcessor.processRequest(request, true);
-
- assertEquals("nbEvents", nbExpectedEvents, 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 < nbExpectedEvents; i++) {
- assertEquals("Distinct events", i + OFFSET, requestedEvents.get(i).getTimestamp().getValue());
- }
- }
-
- // l@Test
- public void testProcessRequestWithNegativeOffset() throws Exception {
-
- final int NB_EVENTS = -1;
- final int BLOCK_SIZE = 1;
- final int OFFSET = -5;
- final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
- int nbExpectedEvents = TmfRequestHandlerStub.MAX_GENERATED_EVENTS;
+ assertEquals("StartTime", TmfTimestamp.BigBang, request.getRange().getStartTime());
+ assertEquals("EndTime", TmfTimestamp.BigCrunch, request.getRange().getEndTime());
+ assertEquals("getIndex", 0, request.getIndex());
+ assertEquals("getNbRequestedEvents", 10, request.getNbRequestedEvents());
+ assertEquals("getBlockize", TmfDataRequest.DEFAULT_BLOCK_SIZE, request.getBlockize());
+ }
+ public void testTmfDataRequestTimeRangeNbEventsBlockSize() {
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
- @Override
- public void handleData() {
- TmfEvent[] events = getData();
- for (TmfEvent e : events) {
- requestedEvents.add(e);
- }
- }
- };
- fProcessor.processRequest(request, true);
-
- assertEquals("nbEvents", nbExpectedEvents, 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 < nbExpectedEvents; i++) {
- assertEquals("Distinct events", i + OFFSET, requestedEvents.get(i).getTimestamp().getValue());
- }
- }
-
- // ========================================================================
- // cancel
- // ========================================================================
-
- @Test
- public void testCancel() throws Exception {
-
- final int NB_EVENTS = 10 * 1000;
- final int BLOCK_SIZE = 100;
- final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+ TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 10, 100);
- TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
- @Override
- public void handleData() {
- TmfEvent[] events = getData();
- for (TmfEvent e : events) {
- requestedEvents.add(e);
- }
- // Cancel request after the first chunk is received
- cancel();
- }
- };
- fProcessor.processRequest(request, true);
-
- assertEquals("nbEvents", BLOCK_SIZE, requestedEvents.size());
- assertTrue("isCompleted", request.isCompleted());
- assertTrue("isCancelled", request.isCancelled());
- }
+ assertEquals("StartTime", TmfTimestamp.BigBang, request.getRange().getStartTime());
+ assertEquals("EndTime", TmfTimestamp.BigCrunch, request.getRange().getEndTime());
+ assertEquals("getIndex", 0, request.getIndex());
+ assertEquals("getNbRequestedEvents", 10, request.getNbRequestedEvents());
+ assertEquals("getBlockize", 100, request.getBlockize());
+ }
}
--- /dev/null
+package org.eclipse.linuxtools.tmf.trace;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AllTests.class.getName());
+ //$JUnit-BEGIN$
+ suite.addTestSuite(TmfTraceTest.class);
+ suite.addTestSuite(TmfExperimentTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
+++ /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.trace;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TmfTraceTest.class,
- TmfExperimentTest.class
-})
-
-public class AllTraceTests {
-
-}
package org.eclipse.linuxtools.tmf.trace;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import java.io.File;
import java.util.Vector;
import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
-import org.junit.BeforeClass;
-import org.junit.Test;
+
+import junit.framework.TestCase;
/**
- * <b><u>TmfEventLogTest</u></b>
+ * <b><u>TmfExperimentTest</u></b>
* <p>
* TODO: Implement me. Please.
*/
-public class TmfExperimentTest {
+public class TmfExperimentTest extends TestCase {
private static final String DIRECTORY = "testfiles";
private static final String TEST_STREAM = "M-Test-10K";
private static ITmfTrace fStream;
private static TmfExperiment fExperiment;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ // ========================================================================
+ // Housekeeping
+ // ========================================================================
+
+ public TmfExperimentTest(String name) throws Exception {
+ super(name);
String directory = new File(".").getCanonicalPath() + File.separator + DIRECTORY;
testfile = directory + File.separator + TEST_STREAM;
fExperiment = new TmfExperiment(EXPERIMENT, new ITmfTrace[] { fStream }, true);
}
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
// ========================================================================
// Constructor
// ========================================================================
- @Test
public void testBasicTmfTrace() {
assertEquals("GetId", EXPERIMENT, fExperiment.getExperimentId());
assertEquals("GetEpoch", TmfTimestamp.BigBang, fExperiment.getEpoch());
// processRequest
// ========================================================================
- @Test
public void testProcessRequestForNbEvents() throws Exception {
final int blockSize = 100;
final int nbEvents = 1000;
final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, nbEvents, blockSize) {
+ final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, nbEvents, blockSize) {
@Override
public void handleData() {
TmfEvent[] events = getData();
}
}
- @Test
public void testProcessRequestForNbEvents2() throws Exception {
final int blockSize = 2 * NB_EVENTS;
final int nbEvents = 1000;
final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, nbEvents, blockSize) {
+ final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, nbEvents, blockSize) {
@Override
public void handleData() {
TmfEvent[] events = getData();
}
}
- @Test
public void testProcessRequestForAllEvents() throws Exception {
final int nbEvents = -1;
final int blockSize = 1;
int nbExpectedEvents = fExperiment.getNbEvents();
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, nbEvents, blockSize) {
+ final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, nbEvents, blockSize) {
@Override
public void handleData() {
TmfEvent[] events = getData();
// cancel
// ========================================================================
- @Test
public void testCancel() throws Exception {
final int nbEvents = NB_EVENTS;
final int blockSize = fDefaultBlockSize;
final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, nbEvents, blockSize) {
+ final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, nbEvents, blockSize) {
@Override
public void handleData() {
TmfEvent[] events = getData();
assertTrue("isCompleted", request.isCompleted());
assertTrue("isCancelled", request.isCancelled());
}
-
}
package org.eclipse.linuxtools.tmf.trace;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import java.io.File;
import java.util.Vector;
import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
-import org.junit.BeforeClass;
-import org.junit.Test;
+
+import junit.framework.TestCase;
/**
- * <b><u>TmfEventStreamTest</u></b>
+ * <b><u>TmfTraceTest</u></b>
* <p>
* TODO: Implement me. Please.
*/
-public class TmfTraceTest {
+public class TmfTraceTest extends TestCase {
private static final String DIRECTORY = "testfiles";
private static final String TEST_STREAM = "M-Test-10K";
private static byte SCALE = (byte) -3;
- /**
- * @throws java.lang.Exception
- */
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ // ========================================================================
+ // Housekeeping
+ // ========================================================================
+
+ public TmfTraceTest(String name) throws Exception {
+ super(name);
String directory = new File(".").getCanonicalPath() + File.separator + DIRECTORY;
testfile = directory + File.separator + TEST_STREAM;
fTrace = new TmfTraceStub(testfile, 500, true);
- }
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
// ========================================================================
- // Constructor
+ // Constructors
// ========================================================================
- @Test
- public void testDefaultConstructor() throws Exception {
+ public void testTmfTraceDefault() throws Exception {
TmfTraceStub trace = new TmfTraceStub(testfile, true);
assertEquals("getCacheSize", TmfTraceStub.DEFAULT_CACHE_SIZE, trace.getCacheSize());
- assertEquals("getTraceSize", NB_EVENTS, trace.getNbEvents());
- assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue());
+ assertEquals("getTraceSize", 0, trace.getNbEvents());
+ assertEquals("getRange-start", 0, trace.getTimeRange().getStartTime().getValue());
+ assertEquals("getRange-end", 0, trace.getTimeRange().getEndTime().getValue());
}
- @Test
- public void testNormalConstructor() throws Exception {
- assertEquals("getCacheSize", 500, fTrace.getCacheSize());
- assertEquals("getTraceSize", NB_EVENTS, fTrace.getNbEvents());
- assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, fTrace.getTimeRange().getEndTime().getValue());
+ public void testTmfTrace() throws Exception {
+ assertEquals("getCacheSize", 500, fTrace.getCacheSize());
+ assertEquals("getTraceSize", 0, fTrace.getNbEvents());
+ assertEquals("getRange-start", 0, fTrace.getTimeRange().getStartTime().getValue());
+ assertEquals("getRange-end", 0, fTrace.getTimeRange().getEndTime().getValue());
}
// ========================================================================
// seek
// ========================================================================
- @Test
public void testSeekOnCacheBoundary() throws Exception {
TmfTraceContext context = fTrace.seekLocation(null);
assertEquals("Event timestamp", 4000, event.getTimestamp().getValue());
}
- @Test
public void testSeekNotOnCacheBoundary() throws Exception {
TmfTraceContext context = fTrace.seekLocation(null);
assertEquals("Event timestamp", 4499, event.getTimestamp().getValue());
}
- @Test
public void testSeekForEventOutOfBounds() throws Exception {
TmfTraceContext context = fTrace.seekLocation(null);
// getNextEvent
// ========================================================================
- @Test
public void testGetNextEvent() throws Exception {
TmfTraceContext context = fTrace.seekLocation(null);
// processRequest
// ========================================================================
- @Test
public void testProcessRequestForNbEvents() throws Exception {
final int BLOCK_SIZE = 100;
final int NB_EVENTS = 1000;
final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
+ final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, NB_EVENTS, BLOCK_SIZE) {
@Override
public void handleData() {
TmfEvent[] events = getData();
}
}
- @Test
public void testProcessRequestForAllEvents() throws Exception {
- final int NB_EVENTS = -1;
final int BLOCK_SIZE = 1;
final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
- long nbExpectedEvents = fTrace.getNbEvents();
+ long nbExpectedEvents = NB_EVENTS;
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
+ final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, NB_EVENTS, BLOCK_SIZE) {
@Override
public void handleData() {
TmfEvent[] events = getData();
};
fTrace.processRequest(request, true);
- assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
+ 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 < nbExpectedEvents; i++) {
+ for (int i = 0; i < NB_EVENTS; i++) {
assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
}
}
// cancel
// ========================================================================
- @Test
public void testCancel() throws Exception {
final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
- final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, NB_EVENTS) {
+ final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, NB_EVENTS, NB_EVENTS) {
@Override
public void handleData() {
TmfEvent[] events = getData();
assertTrue("isCompleted", request.isCompleted());
assertTrue("isCancelled", request.isCancelled());
}
-
}
// ========================================================================
private static final String DIRECTORY = "testfiles";
- private static final String FILE_NAMES[] = { "Test-10", "Test-1K", "Test-10K", "Test-100K", "Test-1M", "Test-10M" };
- private static final int FILE_SIZES[] = { 10 , 1000 , 10000 , 100000 , 1000000 , 10000000 };
+ private static final String FILE_NAMES[] = { "Test-10", "Test-1K", "Test-10K", "Test-100K" };
+ private static final int FILE_SIZES[] = { 10 , 1000 , 10000 , 100000 };
private static final int NB_SOURCES = 15;
private static final int NB_TYPES = 7;
return content;
}
-// @Override
-// public String toString() {
-// Object[] fields = getFields();
-// StringBuilder result = new StringBuilder("[TmfEventContent(");
-// for (int i = 0; i < fields.length; i++) {
-// if (i > 0) result.append(",");
-// result.append(fields[i]);
-// }
-// result.append(")]");
-// return result.toString();
-// }
+ @Override
+ public String toString() {
+ Object[] fields = getFields();
+ String result = "[TmfEventContentStub(";
+ for (int i = 0; i < fields.length; i++) {
+ result += fields[i].toString() + ",";
+ }
+ result += ")]";
+
+ return result;
+ }
}
+++ /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.event;
-
-/**
- * <b><u>TmfEventFormatStub</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class TmfEventFormatStub extends TmfEventFormat {
-
- // ========================================================================
- // Attributes
- // ========================================================================
-
- // ========================================================================
- // Constructors
- // ========================================================================
-
- public TmfEventFormatStub() {
- super(new String[] { "Field1", "Field2", "Field3", "Field4", "Field5" });
- }
-
- // ========================================================================
- // Accessors
- // ========================================================================
-
- // ========================================================================
- // Operators
- // ========================================================================
-
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.event.TmfEventFormat#parse(java.lang.Object)
- */
- @Override
- public TmfEventField[] parse(Object content) {
- TmfEventField field1 = new TmfEventField(1);
- TmfEventField field2 = new TmfEventField(-10);
- TmfEventField field3 = new TmfEventField(true);
- TmfEventField field4 = new TmfEventField("some string");
- TmfEventField field5 = new TmfEventField(new TmfTimestamp(1, (byte) 2, 3));
- return new TmfEventField[] { field1, field2, field3, field4, field5 };
- }
-
- // ========================================================================
- // Helper functions
- // ========================================================================
-
-}
TmfTimestamp endTime = request.getRange().getEndTime();
int blockSize = request.getBlockize();
- int nbRequestedEvents = request.getNbRequestedItems();
+ int nbRequestedEvents = request.getNbRequestedEvents();
if (nbRequestedEvents <= 0) {
nbRequestedEvents = MAX_GENERATED_EVENTS;
}
import org.eclipse.linuxtools.tmf.event.TmfEvent;
import org.eclipse.linuxtools.tmf.event.TmfEventContent;
-import org.eclipse.linuxtools.tmf.event.TmfEventFormat;
import org.eclipse.linuxtools.tmf.event.TmfEventReference;
import org.eclipse.linuxtools.tmf.event.TmfEventSource;
import org.eclipse.linuxtools.tmf.event.TmfEventType;
// Attributes
// ========================================================================
- private final int NB_FORMATS = 10;
- private final TmfEventFormat[] fFormats;
+ private final int NB_TYPES = 10;
+ private final TmfEventType[] fTypes;
// ========================================================================
// Constructors
// ========================================================================
public TmfEventParserStub() {
- fFormats = new TmfEventFormat[NB_FORMATS];
- for (int i = 0; i < NB_FORMATS; i++) {
+ fTypes = new TmfEventType[NB_TYPES];
+ for (int i = 0; i < NB_TYPES; i++) {
Vector<String> format = new Vector<String>();
for (int j = 1; j <= i; j++) {
format.add(new String("Fmt-" + i + "-Fld-" + j));
}
String[] fields = new String[i];
- fFormats[i] = new TmfEventFormat(format.toArray(fields));
+ fTypes[i] = new TmfEventType("Type-" + i, format.toArray(fields));
}
}
// Operators
// ========================================================================
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventParser#parseNextEvent()
- */
static final String typePrefix = "Type-";
public TmfEvent parseNextEvent(ITmfTrace eventStream, TmfTraceContext context) throws IOException {
TmfEvent event = new TmfEvent(
new TmfTimestamp(ts, (byte) -3, 0), // millisecs
new TmfEventSource(source),
- new TmfEventType(type, fFormats[typeIndex]),
- new TmfEventContent(content, fFormats[typeIndex]),
+ fTypes[typeIndex],
new TmfEventReference(name));
- return event;
+ TmfEventContent cnt = new TmfEventContent(event, content);
+ event.setContent(cnt);
+ return event;
} catch (EOFException e) {
}
}
item.setText(extractItemFields(cache[index - cacheStartIndex]));
return;
}
- TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(index, 0, CACHE_SIZE) {
+
+ // *** TODO ***
+ // This is broken!
+ //
+ // This one fails to return any result :
+ // TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(fExperiment.getTimeRange(), index, 1) {
+ // All these will return THE SAME RESULT!
+ // TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(index, 1) {
+ // TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(index+10, 1) {
+ // TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(null, 1) {
+ //
+ // THIS IS ONLY A TEMPORARY FIX!
+
+ TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(index, 1) {
@Override
public void handleData() {
- // No need to synchronize because the request is synchronous
- cache = getData();
- cacheStartIndex = index;
- cacheEndIndex = index + cache.length;
+ TmfEvent[] tmpEvent = getData();
+ if ( (tmpEvent != null) && (tmpEvent.length > 0) ) {
+ cache = tmpEvent;
+ }
+// cacheStartIndex = index;
+// cacheEndIndex = index + cache.length;
}
};
fExperiment.processRequest(request, true);
- item.setText(extractItemFields(cache[0]));
+
+ if (cache[0] != null) {
+ item.setText(extractItemFields(cache[0]));
+ }
+
}
});
}
// Events cache - temporary stuff
- private final int CACHE_SIZE = 100;
+ private final int CACHE_SIZE = 1;
private TmfEvent[] cache;
private int cacheStartIndex = 0;
private int cacheEndIndex = 0;
new Long(event.getTimestamp().getValue()).toString(),
event.getSource().getSourceId().toString(),
event.getType().getTypeId().toString(),
- event.getReference().getValue().toString(),
- event.getContent().getContent()
+ event.getReference().getReference().toString(),
+ event.getContent().toString()
};
}
return fields;
// Perform the updates on the UI thread
fTable.getDisplay().asyncExec(new Runnable() {
public void run() {
- // TODO: Potentially long operation. Add some feedback for the user
+// // TODO: Potentially long operation. Add some feedback for the user
fTable.setSelection(0);
fTable.clearAll();
fTable.setItemCount(fExperiment.getNbEvents());
}
}
-}
\ No newline at end of file
+}
+++ /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.event;
-
-/**
- * <b><u>ITmfContentParser</u></b>
- * <p>
- * Event content parser.
- */
-public interface ITmfContentParser {
-
- public TmfEventField[] parse(Object content);
-}
* For convenience, a free-form reference field is also provided. It could be
* used as e.g. a location marker in the event stream to distinguish between
* otherwise identical events.
+ *
+ * Notice that for performance reasons TmfEvent is NOT immutable. If a copy
+ * of the event is needed, use clone().
*/
-public class TmfEvent extends TmfData {
+public class TmfEvent extends TmfData implements Cloneable {
// ========================================================================
// Attributes
// ========================================================================
- private final TmfTimestamp fEffectiveTimestamp;
- private final TmfTimestamp fOriginalTimestamp;
- private final TmfEventSource fSource;
- private final TmfEventType fType;
- private final TmfEventContent fContent;
- private final TmfEventReference fReference;
+ protected TmfTimestamp fEffectiveTimestamp;
+ protected TmfTimestamp fOriginalTimestamp;
+ protected TmfEventSource fSource;
+ protected TmfEventType fType;
+ protected TmfEventReference fReference;
- // ========================================================================
+ // Content requires a reference to the parent event so it is initialized
+ // using setContent()
+ protected TmfEventContent fContent;
+
+ // ========================================================================
// Constructors
// ========================================================================
/**
- * @param timestamp
+ * @param originalTS
+ * @param effectiveTS
* @param source
* @param type
- * @param content
* @param reference
*/
- public TmfEvent(TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source,
- TmfEventType type, TmfEventContent content, TmfEventReference reference)
+ public TmfEvent(TmfTimestamp originalTS, TmfTimestamp effectiveTS,
+ TmfEventSource source, TmfEventType type, TmfEventReference reference)
{
- fOriginalTimestamp = originalTS;
+ fOriginalTimestamp = originalTS;
fEffectiveTimestamp = effectiveTS;
- fSource = source;
- fType = type;
- fContent = content;
- fReference = reference;
+ fSource = source;
+ fType = type;
+ fReference = reference;
}
/**
* @param timestamp
* @param source
* @param type
- * @param content
* @param reference
*/
public TmfEvent(TmfTimestamp timestamp, TmfEventSource source,
- TmfEventType type, TmfEventContent content, TmfEventReference reference)
+ TmfEventType type, TmfEventReference reference)
{
- this(timestamp, timestamp, source, type, content, reference);
+ this(timestamp, timestamp, source, type, reference);
}
/**
+ * Copy constructor (shallow)
+ *
+ * @param other
*/
- public TmfEvent(TmfEvent other)
- {
- this(other.fOriginalTimestamp, other.fEffectiveTimestamp, other.fSource,
- other.fType, other.fContent, other.fReference);
+ public TmfEvent(TmfEvent other) {
+ assert(other != null);
+ fOriginalTimestamp = other.fOriginalTimestamp;
+ fEffectiveTimestamp = other.fEffectiveTimestamp;
+ fSource = other.fSource;
+ fType = other.fType;
+ fContent = other.fContent;
+ fReference = other.fReference;
+ }
+
+ @SuppressWarnings("unused")
+ private TmfEvent() {
}
// ========================================================================
return fType;
}
+ /**
+ * @return
+ */
+ public void setContent(TmfEventContent content) {
+ fContent = content;
+ }
+
/**
* @return
*/
return fReference;
}
+ // ========================================================================
+ // Operators
+ // ========================================================================
+
+ @Override
+ public TmfEvent clone() {
+ TmfEvent event = new TmfEvent(
+ fOriginalTimestamp.clone(),
+ fEffectiveTimestamp.clone(),
+ fSource.clone(),
+ fType.clone(),
+ fReference.clone());
+ TmfEventContent content = fContent.clone();
+ event.setContent(content);
+ return event;
+ }
+
// TODO: Design a proper format...
@Override
public String toString() {
package org.eclipse.linuxtools.tmf.event;
+
/**
* <b><u>TmfEventContent</u></b>
* <p>
* The event content.
*/
-public class TmfEventContent {
+public class TmfEventContent implements Cloneable {
// ========================================================================
// Attributes
// ========================================================================
- private final TmfEventFormat fFormat;
- private final String fContent;
- private final int fNbFields;
- private TmfEventField[] fFields = null;
+ protected TmfEvent fParentEvent = null;
+ protected Object fRawContent = null;
+ protected Object[] fFields = null;
// ========================================================================
// Constructors
// ========================================================================
/**
+ * @param parent
* @param content
- * @param format
*/
- public TmfEventContent(Object content, TmfEventFormat format) {
- fFormat = format;
- fContent = content.toString();
- fNbFields = fFormat.getLabels().length;
+ public TmfEventContent(TmfEvent parent, Object content) {
+ fParentEvent = parent;
+ fRawContent = content;
}
+ /**
+ * @param other
+ */
+ public TmfEventContent(TmfEventContent other) {
+ assert(other != null);
+ fParentEvent = other.fParentEvent;
+ fRawContent = other.fRawContent;
+ fFields = other.fFields;
+ }
+
+ @SuppressWarnings("unused")
+ private TmfEventContent() {
+ }
+
// ========================================================================
// Accessors
// ========================================================================
/**
- * @return
+ * @return the parent (containing) event
*/
- public String getContent() {
- return fContent;
+ public TmfEvent getEvent() {
+ return fParentEvent;
}
/**
- * @return
+ * @return the event type
*/
- public TmfEventFormat getFormat() {
- return fFormat;
+ public TmfEventType getType() {
+ return fParentEvent.getType();
}
- /**
- * @return
- */
- public int getNbFields() {
- return fNbFields;
- }
+ /**
+ * @return the raw content
+ */
+ public Object getContent() {
+ return fRawContent;
+ }
/**
- * @return
+ * Returns the list of fields in the same order as TmfEventType.getLabels()
+ *
+ * @return the ordered set of fields (optional fields might be null)
*/
- public TmfEventField[] getFields() {
- if (fFields == null) {
- fFields = fFormat.parse(fContent);
- }
+ public Object[] getFields() {
+ if (fFields == null) {
+ parseContent();
+ }
return fFields;
}
* @param id
* @return
*/
- public TmfEventField getField(int id) {
- assert id >= 0 && id < fNbFields;
- if (fFields == null) {
- fFields = fFormat.parse(fContent);
- }
- return fFields[id];
+ public Object getField(String id) throws TmfNoSuchFieldException {
+ if (fFields == null) {
+ parseContent();
+ }
+ return fFields[getType().getFieldIndex(id)];
}
/**
+ * @param n
* @return
*/
- public void setFields(TmfEventField[] fields) {
- fFields = fields;
+ public Object getField(int n) {
+ if (fFields == null) {
+ parseContent();
+ }
+ if (n >= 0 && n < fFields.length)
+ return fFields[n];
+ return null;
+ }
+
+ // ========================================================================
+ // Operators
+ // ========================================================================
+
+ /**
+ * Should be overridden (all fields are null by default)
+ */
+ protected void parseContent() {
+ fFields = new Object[1];
+ fFields[0] = fRawContent;
}
+
+ /**
+ * Clone: shallow copy by default; override for deep copy.
+ */
+ @Override
+ public TmfEventContent clone() {
+ return new TmfEventContent(this);
+ }
+
+ @Override
+ public String toString() {
+ Object[] fields = getFields();
+ String result = "[TmfEventContent(";
+ for (int i = 0; i < fields.length; i++) {
+ result += fields[i].toString() + ",";
+ }
+ result += ")]";
+
+ return result;
+ }
}
* <b><u>TmfEventField</u></b>
* <p>
* A basic event field.
+ *
+ * TODO: Add support for field hierarchy.
*/
-public class TmfEventField {
+public class TmfEventField implements Cloneable {
// ========================================================================
// Attributes
// ========================================================================
- private final Object fValue;
+ private final TmfEventContent fParent;
+ private final String fFieldId;
+ private Object fValue;
// ========================================================================
// Constructors
// ========================================================================
/**
+ * @param parent
+ * @param id
* @param value
*/
- public TmfEventField(Object value) {
- fValue = value;
+ public TmfEventField(TmfEventContent parent, String id, Object value) {
+ fParent = parent;
+ fFieldId = id;
+ fValue = value;
+ }
+
+ /**
+ * @param other
+ */
+ public TmfEventField(TmfEventField other) {
+ assert(other != null);
+ fParent = other.fParent;
+ fFieldId = other.fFieldId;
+ fValue = other.fValue;
+ }
+
+ @SuppressWarnings("unused")
+ private TmfEventField() {
+ fParent = null;
+ fFieldId = null;
+ fValue = null;
}
// ========================================================================
// Accessors
// ========================================================================
+ /**
+ * @return
+ */
+ public TmfEventContent getParent() {
+ return fParent;
+ }
+
+ /**
+ * @return
+ */
+ public String getId() {
+ return fFieldId;
+ }
+
/**
* @return
*/
return fValue;
}
+ /**
+ * @param value
+ */
+ protected void setValue(Object value) {
+ fValue = value;
+ }
+
// ========================================================================
// Operators
// ========================================================================
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
+ /**
+ * Clone: shallow copy by default; override for deep copy.
+ */
+ @Override
+ public TmfEventField clone() {
+ return new TmfEventField(this);
+ }
+
@Override
public String toString() {
- return fValue.toString();
+ return "[TmfEventField(" + fFieldId + ":" + fValue.toString() + ")]";
}
-}
+}
\ No newline at end of file
+++ /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.event;
-
-/**
- * <b><u>TmfEventFormat</u></b>
- * <p>
- * The basic event content format.
- */
-public class TmfEventFormat implements ITmfContentParser {
-
- // ========================================================================
- // Attributes
- // ========================================================================
-
- private final String[] fLabels;
-
- // ========================================================================
- // Constructors
- // ========================================================================
-
- /**
- *
- */
- public TmfEventFormat() {
- this(new String[] { "Content" });
- }
-
- /**
- * @param labels
- */
- public TmfEventFormat(String[] labels) {
- fLabels = labels;
- }
-
- // ========================================================================
- // Accessors
- // ========================================================================
-
- /**
- * @return
- */
- public String[] getLabels() {
- return fLabels;
- }
-
- // ========================================================================
- // Operators
- // ========================================================================
-
- /**
- * The default content parser: returns a single field containing the whole
- * content.
- *
- * @param content
- * @return
- */
- public TmfEventField[] parse(Object content) {
- return new TmfEventField[] { new TmfEventField(content.toString()) };
- }
-
-}
* <p>
* An application-defined event reference.
*/
-public class TmfEventReference {
+public class TmfEventReference implements Cloneable {
// ========================================================================
// Attributes
// ========================================================================
- private final Object fReference;
+ protected Object fReference;
// ========================================================================
// Constructors
// ========================================================================
+ /**
+ *
+ */
+ public TmfEventReference() {
+ this(null);
+ }
+
/**
* @param reference
*/
fReference = reference;
}
+ /**
+ * @param other
+ */
+ public TmfEventReference(TmfEventReference other) {
+ this((other != null) ? other.fReference : null);
+ }
+
// ========================================================================
// Accessors
// ========================================================================
/**
* @return
*/
- public Object getValue() {
+ public Object getReference() {
return fReference;
}
// Operators
// ========================================================================
+ @Override
+ public TmfEventReference clone() {
+ return new TmfEventReference(this);
+ }
+
@Override
public String toString() {
- return fReference.toString();
+ return "[TmfEventReference(" + ((fReference != null) ? fReference.toString() : "null") + ")]";
}
}
* <p>
* The event source.
*/
-public class TmfEventSource {
+public class TmfEventSource implements Cloneable {
// ========================================================================
// Attributes
// ========================================================================
- private final Object fSourceId;
+ protected Object fSourceId;
// ========================================================================
// Constructors
fSourceId = sourceId;
}
+ /**
+ * @param other
+ */
+ public TmfEventSource(TmfEventSource other) {
+ this((other != null) ? other.fSourceId : null);
+ }
+
// ========================================================================
// Accessors
// ========================================================================
// Operators
// ========================================================================
- @Override
+ @Override
+ public TmfEventSource clone() {
+ return new TmfEventSource(this);
+ }
+
+ @Override
public String toString() {
- return fSourceId.toString();
+ return "[TmfEventSource(" + ((fSourceId != null) ? fSourceId.toString() : "null") + ")]";
}
}
package org.eclipse.linuxtools.tmf.event;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* <b><u>TmfEventType</u></b>
* <p>
* The event type.
*/
-public class TmfEventType {
+public class TmfEventType implements Cloneable {
+ // ========================================================================
+ // Constants
+ // ========================================================================
+
+ public static final String DEFAULT_TYPE_ID = "TMF Default Type";
+ public static final String[] DEFAULT_LABELS = new String[] { "Content" };
+
// ========================================================================
// Attributes
// ========================================================================
- private final String fTypeId;
- private final TmfEventFormat fFormat;
+ private final String fTypeId;
+ private final String[] fFieldLabels;
+ private final int fNbFields;
+ private final Map<String, Integer> fFieldMap;
- // ========================================================================
+ // ========================================================================
// Constructors
// ========================================================================
+ /**
+ *
+ */
+ public TmfEventType() {
+ this(DEFAULT_TYPE_ID, DEFAULT_LABELS);
+ }
+
/**
* @param type
* @param format
*/
- public TmfEventType(String typeID, TmfEventFormat format) {
- fTypeId = typeID;
- fFormat = format;
+ public TmfEventType(String typeId, String[] labels) {
+ assert(typeId != null);
+ assert(labels != null);
+ fTypeId = typeId;
+ fFieldLabels = labels;
+ fNbFields = fFieldLabels.length;
+ fFieldMap = new HashMap<String, Integer>();
+ for (int i = 0; i < fNbFields; i++) {
+ fFieldMap.put(fFieldLabels[i], i);
+ }
+ }
+
+ /**
+ * @param other
+ */
+ public TmfEventType(TmfEventType other) {
+ assert(other != null);
+ fTypeId = other.fTypeId;
+ fFieldLabels = other.fFieldLabels;
+ fNbFields = other.fNbFields;
+ fFieldMap = other.fFieldMap;
}
// ========================================================================
return fTypeId;
}
- /**
- * @return
- */
- public TmfEventFormat getFormat() {
- return fFormat;
- }
+ /**
+ * @return
+ */
+ public int getNbFields() {
+ return fNbFields;
+ }
+
+ /**
+ * @return
+ */
+ public int getFieldIndex(String id) throws TmfNoSuchFieldException {
+ Integer index = fFieldMap.get(id);
+ if (index == null)
+ throw(new TmfNoSuchFieldException(id));
+ return index;
+ }
+
+ /**
+ * @return
+ */
+ public String[] getLabels() {
+ return fFieldLabels;
+ }
+
+ /**
+ * @return
+ */
+ public String getLabel(int i) {
+ if (i >= 0 && i < fNbFields)
+ return fFieldLabels[i];
+ return null;
+ }
// ========================================================================
// Operators
// ========================================================================
+ @Override
+ public TmfEventType clone() {
+ return new TmfEventType(this);
+ }
+
@Override
public String toString() {
- return fTypeId.toString();
+ return "[TmfEventType:" + fTypeId + "]";
}
-}
+}
\ No newline at end of file
// Constructors
// ========================================================================
+ /**
+ *
+ */
+ @SuppressWarnings("unused")
+ private TmfTimeRange() {
+ fStartTime = null;
+ fEndTime = null;
+ }
+
/**
* @param startTime
* @param endTime
fStartTime = startTime;
fEndTime = endTime;
}
+
+ /**
+ * @param other
+ */
+ public TmfTimeRange(TmfTimeRange other) {
+ assert(other != null);
+ fStartTime = other.fStartTime;
+ fEndTime = other.fEndTime;
+ }
// ========================================================================
// Accessors
*/
@Override
public String toString() {
- return "[TmfTimeRange (" + fStartTime.toString() + ":" + fEndTime.toString() + ")]";
+ return "[TmfTimeRange(" + fStartTime.toString() + ":" + fEndTime.toString() + ")]";
}
}
package org.eclipse.linuxtools.tmf.event;
-import java.io.Serializable;
/**
* <b><u>TmfTimestamp</u></b>
* <li>a precision to indicate the error on the value (useful for comparing
* timestamps in different scales). Default: 0.
* </ul>
- * To allow synchronization of timestamps from different reference clocks, there
- * is a possibility to "adjust" the timestamp both by changing its scale (traces
- * of different scale) and by adding an offset to its value (clock drift between
- * traces).
+ * To allow synchronization of timestamps from different reference clocks,
+ * there is a possibility to "adjust" the timestamp both by changing its scale
+ * (traces of different scale) and by adding an offset to its value (clock
+ * drift between traces).
* <p>
- * Note that the adjusted timestamp value could be negative e.g. for events that
- * occurred before t0 of the reference clock.
- *
+ * Notice that the adjusted timestamp value could be negative e.g. for events
+ * that occurred before t0 wrt the reference clock.
+ * <p>
+ * Finally, notice that timestamps are immutable.
*/
-public class TmfTimestamp implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = -3196421507276821609L;
+public class TmfTimestamp implements Cloneable {
// ========================================================================
// Attributes
// ========================================================================
- protected final long fValue; // The timestamp value
- protected final byte fScale; // The time scale
- protected final long fPrecision; // The value precision (tolerance)
+ protected long fValue; // The timestamp value
+ protected byte fScale; // The time scale
+ protected long fPrecision; // The value precision (tolerance)
// ========================================================================
// Constants
// ========================================================================
/**
- * Default constructor.
+ * Default constructor
*/
public TmfTimestamp() {
this(0, (byte) 0, 0);
}
/**
- * Simple constructor.
+ * Simple constructor with value only
*/
public TmfTimestamp(long value) {
this(value, (byte) 0, 0);
}
/**
- * Simple constructor with default error value
+ * Simple constructor with value and scale
*
* @param value
* @param scale
}
/**
- * Constructor with measurement error.
+ * Constructor with value, scale and precision
*
* @param value
* @param scale
}
/**
- * Copy constructor.
+ * Copy constructor
*
* @param other
*/
public TmfTimestamp(TmfTimestamp other) {
- this(other.fValue, other.fScale, other.fPrecision);
+ assert(other != null);
+ fValue = other.fValue;
+ fScale = other.fScale;
+ fPrecision = other.fPrecision;
}
// ========================================================================
// ========================================================================
/**
- * @return The timestamp value
+ * @return the timestamp value
*/
public long getValue() {
return fValue;
}
/**
- * @return The timestamp scale
+ * @return the timestamp scale
*/
public byte getScale() {
return fScale;
}
/**
- * @return The timestamp value precision
+ * @return the timestamp value precision
*/
public long getPrecision() {
return fPrecision;
*
* @param reference
* - the reference timestamp to synchronize with
- * @return The adjustment term in the reference time scale
+ * @return the adjustment term in the reference time scale
* @throws TmfNumericalException
*/
public long getAdjustment(TmfTimestamp reference) throws ArithmeticException {
* - the other timestamp
* @param withinPrecision
* - indicates if precision is to be take into consideration
- * @return <li>-1: this timestamp is lower <li>0: timestamps are equal
- * (within precision if requested) <li>1: this timestamp is higher
+ * @return -1: this timestamp is lower
+ * 0: timestamps are equal (within precision if requested)
+ * 1: this timestamp is higher
* @throws TmfNumericalException
*/
public int compareTo(final TmfTimestamp other, boolean withinPrecision) {
}
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
+ @Override
+ public TmfTimestamp clone() {
+ return new TmfTimestamp(this);
+ }
+
@Override
public boolean equals(Object other) {
if (other instanceof TmfTimestamp)
return super.equals(other);
}
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
- return "[TmfTimestamp:" + fValue + "," + fScale + "," + fPrecision + "]";
+ return "[TmfTimestamp(" + fValue + "," + fScale + "," + fPrecision + ")]";
}
}
\ No newline at end of file
private final String fSourcePath;
private final String fFileName;
- private final int fLineNumber;
+ private final int fLineNumber;
// ========================================================================
// Constructors
// ========================================================================
/**
- * The constructor.
- *
- * @param timestamp
+ * @param originalTS
+ * @param effectiveTS
* @param source
* @param type
* @param content
* @param reference
+ * @param path
+ * @param file
+ * @param line
*/
public TmfTraceEvent(TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source,
- TmfEventType type, TmfEventContent content, TmfEventReference reference,
- String path, String file, int line)
+ TmfEventType type, TmfEventReference reference, String path, String file, int line)
{
- super(originalTS, effectiveTS, source, type,content, reference);
+ super(originalTS, effectiveTS, source, type, reference);
fSourcePath = path;
- fFileName = file;
+ fFileName = file;
fLineNumber = line;
}
/**
- * The constructor.
- *
* @param timestamp
* @param source
* @param type
* @param content
* @param reference
+ * @param path
+ * @param file
+ * @param line
*/
public TmfTraceEvent(TmfTimestamp timestamp, TmfEventSource source, TmfEventType type,
- TmfEventContent content, TmfEventReference reference,
- String path, String file, int line)
+ TmfEventReference reference, String path, String file, int line)
{
- super(timestamp, source, type,content, reference);
+ super(timestamp, source, type, reference);
fSourcePath = path;
- fFileName = file;
+ fFileName = file;
fLineNumber = line;
}
+ /**
+ * @param other
+ */
+ public TmfTraceEvent(TmfTraceEvent other) {
+ super(other);
+ fSourcePath = other.fSourcePath;
+ fFileName = other.fFileName;
+ fLineNumber = other.fLineNumber;
+ }
+
// ========================================================================
// Accessors
// ========================================================================
return fLineNumber;
}
+ // ========================================================================
+ // Operators
+ // ========================================================================
+
+ // TODO: Deep copy
+ @Override
+ public TmfTraceEvent clone() {
+ return new TmfTraceEvent(this);
+ }
+
+ // TODO: Proper format
+ @Override
+ public String toString() {
+ return null;
+ }
+
}
* continuous streaming.
* <p>
* The request is processed asynchronously by an ITmfRequestProcessor and,
- * as blocks of data become available, the callback handlePartialData() is
+ * as blocks of data become available, the callback handleData() is
* invoked, synchronously, for each block. When returning from the callback,
* the data instances go out of scope and become eligible for gc. It is
* is thus the responsibility of the requester to either copy or keep a
// Attributes
// ========================================================================
- private final TmfTimeRange fRange; // The requested events timestamp range
- private final int fIndex; // The event index to get
- private final long fOffset; // The synchronization offset to apply
- private final int fNbRequestedItems; // The number of items to read (-1 == the whole range)
+ private final int fIndex; // The index (order) of the requested event
+ private final TmfTimeRange fRange; // The requested events time range
+ private final int fNbRequestedEvents; // The number of events to read (-1 == all in the range)
private final int fBlockSize; // The maximum number of events per chunk
private int fNbEvents; // The number of events read so far
* @param index
* @param nbEvents
*/
- public TmfDataRequest(int index, long offset, int nbEvents) {
- this(null, index, offset, nbEvents, DEFAULT_BLOCK_SIZE);
+ public TmfDataRequest(int index, int nbEvents) {
+ this(null, index, nbEvents, DEFAULT_BLOCK_SIZE);
}
+ public TmfDataRequest(int index, int nbEvents, int blockSize) {
+ this(null, index, nbEvents, blockSize);
+ }
+
/**
* @param range
- * @param offset
- * @param nbEvents
*/
- public TmfDataRequest(TmfTimeRange range, long offset, int nbEvents) {
- this(range, 0, offset, nbEvents, DEFAULT_BLOCK_SIZE);
+ public TmfDataRequest(TmfTimeRange range) {
+ this(range, 0, ALL_EVENTS, DEFAULT_BLOCK_SIZE);
}
/**
* @param range
- * @param offset
- * @param nbItems
- * @param maxBlockSize Size of the largest blocks expected
+ * @param nbEvents
+ */
+ public TmfDataRequest(TmfTimeRange range, int nbEvents) {
+ this(range, 0, nbEvents, DEFAULT_BLOCK_SIZE);
+ }
+ /**
+ * @param range
+ * @param nbEvents
+ * @param blockSize Size of the largest blocks expected
*/
- public TmfDataRequest(TmfTimeRange range, long offset, int nbEvents, int maxBlockSize) {
- this(range, 0, offset, nbEvents, maxBlockSize);
+ public TmfDataRequest(TmfTimeRange range, int nbEvents, int blockSize) {
+ this(range, 0, nbEvents, blockSize);
}
/**
* @param range
* @param index
- * @param offset
- * @param nbItems
- * @param maxBlockSize Size of the largest blocks expected
+ * @param nbEvents
+ * @param blockSize Size of the largest blocks expected
*/
- public TmfDataRequest(TmfTimeRange range, int index, long offset, int nbEvents, int maxBlockSize) {
- fRange = range;
- fIndex = index;
- fOffset = offset;
- fNbRequestedItems = nbEvents;
- fBlockSize = maxBlockSize;
- fNbEvents = 0;
+ private TmfDataRequest(TmfTimeRange range, int index, int nbEvents, int blockSize) {
+ fIndex = index;
+ fRange = range;
+ fNbRequestedEvents = nbEvents;
+ fBlockSize = blockSize;
+ fNbEvents = 0;
}
// ========================================================================
// Accessors
// ========================================================================
+ /**
+ * @return the index
+ */
+ public int getIndex() {
+ return fIndex;
+ }
+
/**
* @return the requested time range
*/
return fRange;
}
- /**
- * @return the index
- */
- public int getIndex() {
- return fIndex;
- }
-
- /**
- * @return the offset
- */
- public long getOffset() {
- return fOffset;
- }
-
/**
* @return the number of requested events (-1 = all)
*/
- public int getNbRequestedItems() {
- return fNbRequestedItems;
+ public int getNbRequestedEvents() {
+ return fNbRequestedEvents;
}
/**
// Extract the general request information
int blockSize = request.getBlockize();
- int nbRequestedEvents = request.getNbRequestedItems();
+ int nbRequestedEvents = request.getNbRequestedEvents();
if (nbRequestedEvents == -1) {
nbRequestedEvents = Integer.MAX_VALUE;
}
job = new IndexingJob(fExperimentId);
job.schedule();
- if (fWaitForIndexCompletion) {
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
- try {
- // TODO: Handle cancel!
- dialog.run(true, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- monitor.beginTask("Indexing " + fExperimentId, IProgressMonitor.UNKNOWN);
- job.join();
- monitor.done();
- }
- });
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ try {
+ job.join();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
+// if (fWaitForIndexCompletion) {
+// ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
+// try {
+// // TODO: Handle cancel!
+// dialog.run(true, true, new IRunnableWithProgress() {
+// public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+// monitor.beginTask("Indexing " + fExperimentId, IProgressMonitor.UNKNOWN);
+// job.join();
+// monitor.done();
+// }
+// });
+// } catch (InvocationTargetException e) {
+// e.printStackTrace();
+// } catch (InterruptedException e) {
+// e.printStackTrace();
+// }
+// }
}
private class IndexingJob extends Job {
public void run() {
// Extract the general request information
int blockSize = request.getBlockize();
- int nbRequestedEvents = request.getNbRequestedItems();
+ int nbRequestedEvents = request.getNbRequestedEvents();
if (nbRequestedEvents == -1) {
nbRequestedEvents = Integer.MAX_VALUE;
}