These conflicts are a little intense, let's fix them one merge at a time...
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Conflicts:
lttng/org.eclipse.linuxtools.ctf.core/META-INF/MANIFEST.MF
lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventFactory.java
lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/OpenExperimentHandler.java
Change-Id: If5589c465c299b4f2c718ae25426c5afe446fce1
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.ctf.core.tests;singleton:=true
Bundle-Activator: org.eclipse.linuxtools.ctf.core.tests.CtfCoreTestPlugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit;bundle-version="4.0.0",
org.eclipse.core.runtime;bundle-version="3.8.0",
- org.eclipse.linuxtools.ctf.core;bundle-version="2.1.0"
+ org.eclipse.linuxtools.ctf.core;bundle-version="3.0.0"
Export-Package: org.eclipse.linuxtools.ctf.core.tests;x-friends:="org.eclipse.linuxtools.lttng.alltests",
org.eclipse.linuxtools.ctf.core.tests.event;x-internal:=true,
org.eclipse.linuxtools.ctf.core.tests.headless;x-internal:=true,
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<name>Linux Tools CTF Core Tests Plug-in</name>
<groupId>org.eclipse.linuxtools.ctf</groupId>
<artifactId>org.eclipse.linuxtools.ctf.core.tests</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<build>
private static final String[] testTracePaths = {
"../org.eclipse.linuxtools.ctf.core.tests/traces/kernel",
"../org.eclipse.linuxtools.ctf.core.tests/traces/trace2",
- "../org.eclipse.linuxtools.ctf.core.tests/traces/kernel_vm"
+ "../org.eclipse.linuxtools.ctf.core.tests/traces/kernel_vm",
+ "../org.eclipse.linuxtools.ctf.core.tests/traces/synctraces/scp_src",
+ "../org.eclipse.linuxtools.ctf.core.tests/traces/synctraces/scp_dest"
};
private static CTFTrace[] testTraces = new CTFTrace[testTracePaths.length];
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
-import java.util.List;
import java.util.Random;
+import java.util.TreeSet;
import org.eclipse.linuxtools.ctf.core.event.CTFCallsite;
import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces;
}
private long testMain() {
- List<CTFCallsite> l = fTrace.getCallsiteCandidates(callsites[0]);
+ TreeSet<CTFCallsite> l = fTrace.getCallsiteCandidates(callsites[0]);
CTFCallsite cs = fTrace.getCallsite(1);
CTFCallsite cs1 = fTrace.getCallsite(callsites[0]);
CTFCallsite cs2 = fTrace.getCallsite(callsites[0], 1);
* Contributors:
* Matthew Khouzam - Initial API and implementation
* Marc-Andre Laperle - Test in traces directory recursively
+ * Simon Delisle - Add test for getCallsite(eventName, ip)
*******************************************************************************/
package org.eclipse.linuxtools.ctf.core.tests.trace;
}
}
+ /**
+ * Test for getCallsite(eventName, ip)
+ */
+ @Test
+ public void callsitePosition(){
+ long ip1 = 2;
+ long ip2 = 5;
+ long ip3 = 7;
+ CTFTrace callsiteTest = CtfTestTraces.getTestTraceFromFile(TRACE_INDEX);
+ callsiteTest.addCallsite("testEvent", null, ip1, null, 23);
+ callsiteTest.addCallsite("testEvent", null, ip2, null, 50);
+ callsiteTest.addCallsite("testEvent", null, ip3, null, 15);
+
+ assertEquals(2, (callsiteTest.getCallsite("testEvent", 1)).getIp());
+ assertEquals(2, (callsiteTest.getCallsite("testEvent", 2)).getIp());
+ assertEquals(5, (callsiteTest.getCallsite("testEvent", 3)).getIp());
+ assertEquals(5, (callsiteTest.getCallsite("testEvent", 5)).getIp());
+ assertEquals(7, (callsiteTest.getCallsite("testEvent", 6)).getIp());
+ assertEquals(7, (callsiteTest.getCallsite("testEvent", 7)).getIp());
+ assertEquals(7, (callsiteTest.getCallsite("testEvent", 8)).getIp());
+ }
+
}
String result = fixture.toString();
assertNotNull(result);
}
+
+ /**
+ * Run the IntegerDefinition formatNumber(Long, int, boolean) method test
+ * for unsigned values.
+ */
+ @Test
+ public void testFormatNumber_unsignedLong() {
+
+ long unsignedLongValue = -64;
+ String result = IntegerDefinition.formatNumber(unsignedLongValue, 10, false);
+ // -64 + 2^64 = 18446744073709551552
+ assertEquals("18446744073709551552", result);
+
+ unsignedLongValue = -131940199973272L;
+ result = IntegerDefinition.formatNumber(unsignedLongValue, 10, false);
+ // -131940199973272l + 2^64 = 18446612133509578344
+ assertEquals("18446612133509578344", result);
+
+ unsignedLongValue = 123456789L;
+ result = IntegerDefinition.formatNumber(unsignedLongValue, 10, false);
+ assertEquals("123456789", result);
+ }
+
+ /**
+ * Run the IntegerDefinition formatNumber(Long, int, boolean) method test
+ * for signed values.
+ */
+ @Test
+ public void testFormatNumber_signedLong() {
+ long signedValue = -64L;
+ String result = IntegerDefinition.formatNumber(signedValue, 10, true);
+ assertEquals("-64", result);
+
+ signedValue = -131940199973272L;
+ result = IntegerDefinition.formatNumber(signedValue, 10, true);
+ assertEquals("-131940199973272", result);
+
+ signedValue = 123456789L;
+ result = IntegerDefinition.formatNumber(signedValue, 10, true);
+ assertEquals("123456789", result);
+ }
}
/ctf-testsuite
/kernel
/kernel_vm
+/synctraces
/trace2
*.ht
# CTF test suite, used for testing CTF parser compliance
git clone https://github.com/efficios/ctf-testsuite.git
+
+# Trace used by the lttng2 kernel to match packets and synchronize
+wget http://www.dorsal.polymtl.ca/~gbastien/traces/synctraces.tar.gz -O- | tar xvzf - &&
+
<get ignoreerrors="true" dest="sample-ctf-trace-20120412.tar.bz2" skipexisting="true" src="http://lttng.org/files/samples/sample-ctf-trace-20120412.tar.bz2"/>
<get ignoreerrors="true" dest="trace2.tar.bz2" skipexisting="true" src="http://www.dorsal.polymtl.ca/~alexmont/data/trace2.tar.bz2"/>
<get ignoreerrors="true" dest="kernel_vm.tar.bz2" skipexisting="true" src="http://www.dorsal.polymtl.ca/~alexmont/data/kernel_vm.tar.bz2" />
+ <get ignoreerrors="true" dest="synctraces.tar.gz" skipexisting="true" src="http://www.dorsal.polymtl.ca/~gbastien/traces/synctraces.tar.gz" />
<exec executable = "git" failifexecutionfails="false">
<arg value = "clone"/>
<arg value = "https://github.com/efficios/ctf-testsuite.git"/>
<available file="sample-ctf-trace-20120412.tar.bz2"/>
<available file="trace2.tar.bz2"/>
<available file="kernel_vm.tar.bz2" />
+ <available file="synctraces.tar.gz" />
</and>
</condition>
<antcall target="extractTraces"/>
<bunzip2 src="sample-ctf-trace-20120412.tar.bz2"/>
<bunzip2 src="trace2.tar.bz2"/>
<bunzip2 src="kernel_vm.tar.bz2" />
+ <gunzip src="synctraces.tar.gz" />
<untar src="sample-ctf-trace-20120412.tar" dest="." />
<untar src="trace2.tar" dest="." />
<untar src="kernel_vm.tar" dest="." />
+ <untar src="synctraces.tar" dest="." />
<echo message="Traces extracted successfully"/>
</target>
</project>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.ctf.core;singleton:=true
Bundle-Activator: org.eclipse.linuxtools.internal.ctf.core.Activator
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.linuxtools.ctf.parser;bundle-version="1.0.0"
+ org.eclipse.linuxtools.ctf.parser;bundle-version="3.0.0"
Export-Package: org.eclipse.linuxtools.ctf.core,
org.eclipse.linuxtools.ctf.core.event,
org.eclipse.linuxtools.ctf.core.event.io,
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<name>Linux Tools CTF Core Plug-in</name>
<groupId>org.eclipse.linuxtools.ctf</groupId>
<artifactId>org.eclipse.linuxtools.ctf.core</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<build>
package org.eclipse.linuxtools.ctf.core.event.types;
+import java.math.BigInteger;
import java.nio.ByteOrder;
import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
/**
* A CTF integer definition.
*
- * The definition of a integer basic data type. It will take the data
- * from a trace and store it (and make it fit) as a long.
+ * The definition of a integer basic data type. It will take the data from a
+ * trace and store it (and make it fit) as a long.
*
* @version 1.0
* @author Matthew Khouzam
/**
* Constructor
- * @param declaration the parent declaration
- * @param definitionScope the parent scope
- * @param fieldName the field name
+ *
+ * @param declaration
+ * the parent declaration
+ * @param definitionScope
+ * the parent scope
+ * @param fieldName
+ * the field name
*/
public IntegerDefinition(IntegerDeclaration declaration,
IDefinitionScope definitionScope, String fieldName) {
/**
* Gets the value of the integer
+ *
* @return the value of the integer (in long)
*/
public long getValue() {
/**
* Sets the value of an integer
- * @param val the value
+ *
+ * @param val
+ * the value
*/
public void setValue(long val) {
value = val;
return declaration;
}
-
-
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
char c = (char) value;
return Character.toString(c);
}
- return String.valueOf(value);
+ return formatNumber(value, declaration.getBase(), declaration.isSigned());
+ }
+
+ /**
+ * Print a numeric value as a string in a given base
+ *
+ * @param value
+ * The value to print as string
+ * @param base
+ * The base for this value
+ * @param signed
+ * Is the value signed or not
+ * @return formatted number string
+ * @since 3.0
+ */
+ public static final String formatNumber(long value, int base, boolean signed) {
+ String s;
+ /* Format the number correctly according to the integer's base */
+ switch (base) {
+ case 2:
+ s = "0b" + Long.toBinaryString(value); //$NON-NLS-1$
+ break;
+ case 8:
+ s = "0" + Long.toOctalString(value); //$NON-NLS-1$
+ break;
+ case 16:
+ s = "0x" + Long.toHexString(value); //$NON-NLS-1$
+ break;
+ case 10:
+ default:
+ /* For non-standard base, we'll just print it as a decimal number */
+ if (!signed && value < 0) {
+ /*
+ * Since there are no 'unsigned long', handle this case with
+ * BigInteger
+ */
+ BigInteger bigInteger = BigInteger.valueOf(value);
+ /*
+ * we add 2^64 to the negative number to get the real unsigned
+ * value
+ */
+ bigInteger = bigInteger.add(BigInteger.valueOf(1).shiftLeft(64));
+ s = bigInteger.toString();
+ } else {
+ s = Long.toString(value);
+ }
+ break;
+ }
+ return s;
}
}
* Contributors:
* Matthew Khouzam - Initial API and implementation
* Alexandre Montplaisir - Initial API and implementation
+ * Simon Delisle - Replace LinkedList by TreeSet in callsitesByName attribute
*******************************************************************************/
package org.eclipse.linuxtools.ctf.core.trace;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.linuxtools.ctf.core.event.types.IntegerDefinition;
import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
import org.eclipse.linuxtools.ctf.core.event.types.StructDefinition;
+import org.eclipse.linuxtools.internal.ctf.core.event.CTFCallsiteComparator;
import org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions.ParseException;
import org.eclipse.linuxtools.internal.ctf.core.trace.StreamInputPacketIndex;
private final Map<StreamInput, StreamInputPacketIndex> indexes = new HashMap<StreamInput, StreamInputPacketIndex>();
/** Callsite helpers */
- private Map<String, LinkedList<CTFCallsite>> callsitesByName = new HashMap<String, LinkedList<CTFCallsite>>();
+ private CTFCallsiteComparator ctfCallsiteComparator = new CTFCallsiteComparator();
+
+ private Map<String, TreeSet<CTFCallsite>> callsitesByName = new HashMap<String, TreeSet<CTFCallsite>>();
/** Callsite helpers */
private TreeSet<CTFCallsite> callsitesByIP = new TreeSet<CTFCallsite>();
String fileName, long lineNumber) {
final CTFCallsite cs = new CTFCallsite(eventName, funcName, ip,
fileName, lineNumber);
- LinkedList<CTFCallsite> csl = callsitesByName.get(eventName);
+ TreeSet<CTFCallsite> csl = callsitesByName.get(eventName);
if (csl == null) {
- csl = new LinkedList<CTFCallsite>();
+ csl = new TreeSet<CTFCallsite>(ctfCallsiteComparator);
callsitesByName.put(eventName, csl);
}
- ListIterator<CTFCallsite> iter = csl.listIterator();
- int index = 0;
- for (; index < csl.size(); index++) {
- if (iter.next().compareTo(cs) < 0) {
- break;
- }
- }
-
- csl.add(index, cs);
+ csl.add(cs);
callsitesByIP.add(cs);
}
/**
- * Gets the list of callsites associated to an event name. O(1)
+ * Gets the set of callsites associated to an event name. O(1)
*
* @param eventName
* the event name
- * @return the callsite list can be empty
- * @since 1.2
+ * @return the callsite set can be empty
+ * @since 3.0
*/
- public List<CTFCallsite> getCallsiteCandidates(String eventName) {
- LinkedList<CTFCallsite> retVal = callsitesByName.get(eventName);
+ public TreeSet<CTFCallsite> getCallsiteCandidates(String eventName) {
+ TreeSet<CTFCallsite> retVal = callsitesByName.get(eventName);
if (retVal == null) {
- retVal = new LinkedList<CTFCallsite>();
+ retVal = new TreeSet<CTFCallsite>(ctfCallsiteComparator);
}
return retVal;
}
* @since 1.2
*/
public CTFCallsite getCallsite(String eventName) {
- LinkedList<CTFCallsite> callsites = callsitesByName.get(eventName);
+ TreeSet<CTFCallsite> callsites = callsitesByName.get(eventName);
if (callsites != null) {
- return callsites.getFirst();
+ return callsites.first();
}
return null;
}
* @return the closest matching callsite, can be null
*/
public CTFCallsite getCallsite(String eventName, long ip) {
- final LinkedList<CTFCallsite> candidates = callsitesByName.get(eventName);
+ final TreeSet<CTFCallsite> candidates = callsitesByName.get(eventName);
final CTFCallsite dummyCs = new CTFCallsite(null, null, ip, null, -1);
- final int pos = Collections.binarySearch(candidates, dummyCs) + 1;
- if (pos >= candidates.size()) {
- return null;
+ final CTFCallsite callsite = candidates.ceiling(dummyCs);
+ if (callsite == null) {
+ return candidates.floor(dummyCs);
}
- return candidates.get(pos);
+ return callsite;
}
-
}
class MetadataFileFilter implements FileFilter {
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon Delisle - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.ctf.core.event;
+
+import java.util.Comparator;
+
+import org.eclipse.linuxtools.ctf.core.event.CTFCallsite;
+
+/**
+ * Comparator for CTFCallsite
+ *
+ * @author Simon Delisle
+ * @since 3.0
+ *
+ */
+public class CTFCallsiteComparator implements Comparator<CTFCallsite> {
+
+ private static final long MASK32 = 0x00000000ffffffffL;
+
+ /*
+ * The callsites will be sorted by calling addresses. To do this we take IPs
+ * (instruction pointers) and compare them. Java only supports signed
+ * operation and since memory addresses are unsigned, we will convert the
+ * longs into integers that contain the high and low bytes and compare them.
+ */
+ @Override
+ public int compare(CTFCallsite o1, CTFCallsite o2) {
+ /*
+ * mask32 is 32 zeros followed by 32 ones, when we bitwise and this it
+ * will return the lower 32 bits
+ */
+
+ long other = o2.getIp();
+ /*
+ * To get a high int: we downshift by 32 and bitwise and with the mask
+ * to get rid of the sign
+ *
+ * To get the low int: we bitwise and with the mask.
+ */
+ long otherHigh = (other >> 32) & MASK32;
+ long otherLow = other & MASK32;
+ long ownHigh = (o1.getIp() >> 32) & MASK32;
+ long ownLow = o1.getIp() & MASK32;
+ /* are the high values different, if so ignore the lower values */
+ if (ownHigh > otherHigh) {
+ return 1;
+ }
+ if (ownHigh < otherHigh ) {
+ return -1;
+ }
+ /* the high values are the same, compare the lower values */
+ if (ownLow > otherLow) {
+ return 1;
+ }
+ if (ownLow < otherLow) {
+ return -1;
+ }
+ /* the values are identical */
+ return 0;
+ }
+
+}
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.ctf.parser
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<name>Linux Tools CTF Parser Plug-in</name>
<groupId>org.eclipse.linuxtools.ctf</groupId>
<artifactId>org.eclipse.linuxtools.ctf.parser</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<build>
<feature
id="org.eclipse.linuxtools.ctf"
label="%featureName"
- version="2.1.0.qualifier"
+ version="3.0.0.qualifier"
provider-name="%featureProvider"
license-feature="org.eclipse.linuxtools.license.feature"
license-feature-version="1.0.0.qualifier">
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<name>Linux Tools CTF (Common Trace Format) Feature</name>
<artifactId>org.eclipse.linuxtools.ctf</artifactId>
<groupId>org.eclipse.linuxtools.ctf</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.gdbtrace.core.tests;singleton:=true
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit;bundle-version="4.0.0",
org.eclipse.core.runtime,
- org.eclipse.linuxtools.gdbtrace.core;bundle-version="1.1.0"
+ org.eclipse.linuxtools.gdbtrace.core;bundle-version="3.0.0"
Export-Package: org.eclipse.linuxtools.gdbtrace.core.tests
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.gdbtrace.core.tests</artifactId>
<groupId>org.eclipse.linuxtools.gdbtrace</groupId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<name>Linux Tools GDB Tracepoint Analysis Core Tests Plug-in</name>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.linuxtools.gdbtrace.core;singleton:=true
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.linuxtools.internal.gdbtrace.core.GdbTraceCorePlugin
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui.ide,
org.eclipse.debug.core,
org.eclipse.debug.ui,
- org.eclipse.linuxtools.tmf.core;bundle-version="2.1.0",
- org.eclipse.linuxtools.tmf.ui;bundle-version="2.1.0"
+ org.eclipse.linuxtools.tmf.core;bundle-version="3.0.0",
+ org.eclipse.linuxtools.tmf.ui;bundle-version="3.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: %Bundle-Vendor
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.gdbtrace.core</artifactId>
<groupId>org.eclipse.linuxtools.gdbtrace</groupId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools GDB Tracepoint Analysis Core Plug-in</name>
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
/**
* GDB Tracepoint extension of TmfTrace. This class implements the necessary
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.gdbtrace.help;singleton:=true
Require-Bundle: org.eclipse.help
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.gdbtrace.help</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools GDB Tracepoint Analysis Help Plug-in</name>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.gdbtrace.ui.tests;singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.junit;bundle-version="4.0.0",
org.eclipse.core.runtime,
org.eclipse.ui,
- org.eclipse.linuxtools.gdbtrace.ui;bundle-version="1.1.0"
+ org.eclipse.linuxtools.gdbtrace.ui;bundle-version="3.0.0"
Export-Package: org.eclipse.linuxtools.gdbtrace.ui.tests
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.gdbtrace.ui.tests</artifactId>
<groupId>org.eclipse.linuxtools.gdbtrace</groupId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<name>Linux Tools GDB Tracepoint Analysis UI Tests Plug-in</name>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
Bundle-SymbolicName: org.eclipse.linuxtools.gdbtrace.ui;singleton:=true
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.linuxtools.internal.gdbtrace.ui.GdbTraceUIPlugin
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui.console,
org.eclipse.ui.ide,
org.eclipse.debug.ui,
- org.eclipse.linuxtools.tmf.core;bundle-version="2.1.0",
- org.eclipse.linuxtools.tmf.ui;bundle-version="2.1.0",
- org.eclipse.linuxtools.gdbtrace.core;bundle-version="1.1.0"
+ org.eclipse.linuxtools.tmf.core;bundle-version="3.0.0",
+ org.eclipse.linuxtools.tmf.ui;bundle-version="3.0.0",
+ org.eclipse.linuxtools.gdbtrace.core;bundle-version="3.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.eclipse.linuxtools.internal.gdbtrace.ui;x-friends:="org.eclipse.linuxtools.gdbtrace.ui.tests",
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.gdbtrace.ui</artifactId>
<groupId>org.eclipse.linuxtools.gdbtrace</groupId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools GDB Tracepoint Analysis UI Plug-in</name>
<feature
id="org.eclipse.linuxtools.gdbtrace"
label="%featureName"
- version="1.1.0.qualifier"
+ version="3.0.0.qualifier"
provider-name="%featureProvider"
license-feature="org.eclipse.linuxtools.license.feature"
license-feature-version="1.0.0.qualifier">
<import plugin="org.eclipse.cdt.dsf"/>
<import plugin="org.eclipse.cdt.dsf.gdb"/>
<import plugin="org.eclipse.cdt.dsf.gdb.ui"/>
- <import plugin="org.eclipse.linuxtools.tmf.core" version="2.1.0" match="greaterOrEqual"/>
- <import plugin="org.eclipse.linuxtools.tmf.ui" version="2.1.0" match="greaterOrEqual"/>
- <import plugin="org.eclipse.linuxtools.gdbtrace.core" version="1.1.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.tmf.core" version="3.0.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.tmf.ui" version="3.0.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.gdbtrace.core" version="3.0.0" match="greaterOrEqual"/>
</requires>
<plugin
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.gdbtrace</artifactId>
<groupId>org.eclipse.linuxtools.gdbtrace</groupId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
<name>Linux Tools GDB Tracepoint Analysis Feature</name>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.lttng.help; singleton:=true
Require-Bundle: org.eclipse.help
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng.help</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools LTTng Help Plug-in</name>
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng.releng-site</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<name>Linux Tools LTTng Repository</name>
<packaging>eclipse-repository</packaging>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.lttng2.core.tests;singleton:=true
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit;bundle-version="4.0.0",
org.eclipse.core.runtime,
- org.eclipse.linuxtools.lttng2.core;bundle-version="2.1.0"
+ org.eclipse.linuxtools.lttng2.core;bundle-version="3.0.0"
Export-Package: org.eclipse.linuxtools.lttng2.core.tests;x-friends:="org.eclipse.linuxtools.lttng.alltests",
org.eclipse.linuxtools.lttng2.core.tests.control.model.impl;x-internal:=true
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng2.core.tests</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<name>Linux Tools LTTng Core Tests Plug-in</name>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.lttng2.core;singleton:=true
Bundle-Activator: org.eclipse.linuxtools.internal.lttng2.core.Activator
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng2.core</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools LTTng Core Plug-in</name>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.lttng2.kernel.core.tests;singleton:=true
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit;bundle-version="4.0.0",
org.eclipse.core.runtime,
- org.eclipse.linuxtools.tmf.core;bundle-version="2.1.0",
- org.eclipse.linuxtools.tmf.core.tests;bundle-version="2.1.0",
- org.eclipse.linuxtools.lttng2.kernel.core;bundle-version="2.1.0"
-Export-Package: org.eclipse.linuxtools.lttng2.kernel.core.tests;x-friends:="org.eclipse.linuxtools.lttng.alltests",
- org.eclipse.linuxtools.lttng2.kernel.core.tests.headless;x-internal:=true,
- org.eclipse.linuxtools.lttng2.kernel.core.tests.stateprovider;x-internal:=true
+ org.eclipse.linuxtools.tmf.core;bundle-version="3.0.0",
+ org.eclipse.linuxtools.tmf.core.tests;bundle-version="3.0.0",
+ org.eclipse.linuxtools.lttng2.kernel.core;bundle-version="3.0.0",
+ org.eclipse.core.resources
+Export-Package: org.eclipse.linuxtools.lttng2.kernel.core.tests,
+ org.eclipse.linuxtools.lttng2.kernel.core.tests.event.matchandsync,
+ org.eclipse.linuxtools.lttng2.kernel.core.tests.headless,
+ org.eclipse.linuxtools.lttng2.kernel.core.tests.stateprovider
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng2.kernel.core.tests</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<name>Linux Tools LTTng Kernel Analysis Core Tests Plug-in</name>
@RunWith(Suite.class)
@Suite.SuiteClasses({
ActivatorTest.class,
- org.eclipse.linuxtools.lttng2.kernel.core.tests.stateprovider.TestAll.class
+ org.eclipse.linuxtools.lttng2.kernel.core.tests.stateprovider.TestAll.class,
+ org.eclipse.linuxtools.lttng2.kernel.core.tests.event.matchandsync.AllTests.class
})
public class AllTests { }
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng2.kernel.core.tests.event.matchandsync;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite for org.eclipse.linuxtools.lttng2.kernel.core.tests.event.matching
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ MatchAndSyncTest.class,
+ ExperimentSyncTest.class
+})
+public class AllTests {
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng2.kernel.core.tests.event.matchandsync;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.eclipse.linuxtools.lttng2.kernel.core.event.matching.TcpEventMatching;
+import org.eclipse.linuxtools.lttng2.kernel.core.event.matching.TcpLttngEventMatching;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventMatching;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.synchronization.ITmfTimestampTransform;
+import org.eclipse.linuxtools.tmf.core.synchronization.SynchronizationAlgorithm;
+import org.eclipse.linuxtools.tmf.core.synchronization.TmfTimestampTransform;
+import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests for experiment syncing
+ *
+ * @author Geneviève Bastien
+ */
+@SuppressWarnings("nls")
+public class ExperimentSyncTest {
+
+ private static final String EXPERIMENT = "MyExperiment";
+ private static int BLOCK_SIZE = 1000;
+
+ private static ITmfTrace[] fTraces;
+ private static TmfExperiment fExperiment;
+
+ /**
+ * Setup the traces and experiment
+ */
+ @Before
+ public void setUp() {
+ CtfTmfTrace trace1 = CtfTmfTestTraces.getTestTrace(3);
+ CtfTmfTrace trace2 = CtfTmfTestTraces.getTestTrace(4);
+
+ fTraces = new CtfTmfTrace[2];
+ fTraces[0] = trace1;
+ fTraces[1] = trace2;
+
+ fExperiment = new TmfExperiment(trace1.getEventType(), EXPERIMENT, fTraces, BLOCK_SIZE);
+
+ TmfEventMatching.registerMatchObject(new TcpEventMatching());
+ TmfEventMatching.registerMatchObject(new TcpLttngEventMatching());
+ }
+
+ /**
+ * Reset the timestamp transforms on the traces
+ */
+ @After
+ public void cleanUp() {
+ fTraces[0].setTimestampTransform(TmfTimestampTransform.IDENTITY);
+ fTraces[1].setTimestampTransform(TmfTimestampTransform.IDENTITY);
+ }
+
+ /**
+ * Testing experiment synchronization
+ */
+ @Test
+ public void testExperimentSync() {
+ try {
+ SynchronizationAlgorithm syncAlgo = fExperiment.synchronizeTraces(true);
+
+ ITmfTimestampTransform tt1, tt2;
+
+ tt1 = syncAlgo.getTimestampTransform(fTraces[0]);
+ tt2 = syncAlgo.getTimestampTransform(fTraces[1]);
+
+ fTraces[0].setTimestampTransform(tt1);
+ fTraces[1].setTimestampTransform(tt2);
+
+ assertEquals("TmfTimestampTransform [ IDENTITY ]", tt2.toString());
+ assertEquals("TmfTimestampLinear [ alpha = 0.9999413783703139011056845831168394, beta = 79796507913179.33347660124688298171 ]", tt1.toString());
+
+ assertEquals(syncAlgo.getTimestampTransform(fTraces[0].getName()),fTraces[0].getTimestampTransform());
+ assertEquals(syncAlgo.getTimestampTransform(fTraces[1].getName()),fTraces[1].getTimestampTransform());
+
+ } catch (TmfTraceException e) {
+ fail("Exception thrown in experiment synchronization " + e.getMessage());
+ }
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng2.kernel.core.tests.event.matchandsync;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.linuxtools.lttng2.kernel.core.event.matching.TcpEventMatching;
+import org.eclipse.linuxtools.lttng2.kernel.core.event.matching.TcpLttngEventMatching;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventMatching;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfNetworkEventMatching;
+import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces;
+import org.junit.Test;
+
+/**
+ * Tests for {@link TcpEventMatching}
+ *
+ * @author Geneviève Bastien
+ */
+@SuppressWarnings("nls")
+public class MatchAndSyncTest {
+
+ /**
+ * Testing the packet matching
+ */
+ @Test
+ public void testMatching() {
+ final String cr = System.getProperty("line.separator");
+ CtfTmfTrace trace1 = CtfTmfTestTraces.getTestTrace(3);
+ CtfTmfTrace trace2 = CtfTmfTestTraces.getTestTrace(4);
+
+ CtfTmfTrace[] tracearr = new CtfTmfTrace[2];
+ tracearr[0] = trace1;
+ tracearr[1] = trace2;
+
+ TmfEventMatching.registerMatchObject(new TcpEventMatching());
+ TmfEventMatching.registerMatchObject(new TcpLttngEventMatching());
+
+ TmfNetworkEventMatching twoTraceMatch = new TmfNetworkEventMatching(tracearr);
+ assertTrue(twoTraceMatch.matchEvents());
+
+ String stats = twoTraceMatch.toString();
+ assertEquals("TmfEventMatches [ Number of matches found: 46 ]" +
+ "Trace 0:" + cr +
+ " 3 unmatched incoming events" + cr +
+ " 2 unmatched outgoing events" + cr +
+ "Trace 1:" + cr +
+ " 2 unmatched incoming events" + cr +
+ " 1 unmatched outgoing events" + cr, stats);
+ }
+
+}
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.lttng2.kernel.core;singleton:=true
Bundle-Activator: org.eclipse.linuxtools.internal.lttng2.kernel.core.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
- org.eclipse.linuxtools.ctf.core;bundle-version="2.1.0",
- org.eclipse.linuxtools.tmf.core;bundle-version="2.1.0"
+ org.eclipse.linuxtools.ctf.core;bundle-version="3.0.0",
+ org.eclipse.linuxtools.tmf.core;bundle-version="3.0.0"
Export-Package: org.eclipse.linuxtools.internal.lttng2.kernel.core;x-friends:="org.eclipse.linuxtools.lttng2.kernel.ui,org.eclipse.linuxtools.lttng2.kernel.core.tests",
org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider;x-friends:="org.eclipse.linuxtools.lttng2.kernel.core.tests",
- org.eclipse.linuxtools.lttng2.kernel.core.trace
+ org.eclipse.linuxtools.lttng2.kernel.core.trace,
+ org.eclipse.linuxtools.lttng2.kernel.core.event.matching
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng2.kernel.core</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools LTTng Kernel Analysis Core Plug-in</name>
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.lttng2.kernel.core.event.matching.TcpEventMatching;
+import org.eclipse.linuxtools.lttng2.kernel.core.event.matching.TcpLttngEventMatching;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventMatching;
import org.osgi.framework.BundleContext;
/**
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
+ TmfEventMatching.registerMatchObject(new TcpEventMatching());
+ TmfEventMatching.registerMatchObject(new TcpLttngEventMatching());
}
@Override
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng2.kernel.core;
+
+/**
+ * This file defines all the known event and field names used to trace socket
+ * connection for both the addons module method (
+ * {@link org.eclipse.linuxtools.lttng2.kernel.core.event.matching.TcpEventMatching}
+ * ) and the net_data_experimental branch (
+ * {@link org.eclipse.linuxtools.lttng2.kernel.core.event.matching.TcpLttngEventMatching}
+ * ).
+ *
+ * These events should be eventually mainlined and when this happens, this class
+ * won't be necessary anymore and they should be moved to {@link LttngStrings}
+ * class
+ *
+ *
+ * @author Geneviève Bastien
+ */
+@SuppressWarnings({ "javadoc", "nls" })
+public interface TcpEventStrings {
+
+ /* Event names */
+ public static final String INET_CONNECT = "inet_connect";
+ public static final String INET_SOCK_CREATE = "inet_sock_create";
+ public static final String INET_SOCK_LOCAL_OUT = "inet_sock_local_out";
+ public static final String INET_SOCK_LOCAL_IN = "inet_sock_local_in";
+ public static final String INET_SOCK_CLONE = "inet_sock_clone";
+ public static final String INET_ACCEPT = "inet_accept";
+ public static final String INET_SOCK_DELETE = "inet_sock_delete";
+ public static final String NETIF_RECEIVE_SKB = "netif_receive_skb";
+ public static final String NET_DEV_QUEUE = "net_dev_queue";
+
+ /* Field names */
+ public static final String SEQ = "seq";
+ public static final String SK = "sk";
+ public static final String OSK = "osk";
+ public static final String NSK = "nsk";
+ public static final String SPORT = "sport";
+ public static final String DPORT = "dport";
+ public static final String SADDR = "saddr";
+ public static final String DADDR = "daddr";
+ public static final String ACKSEQ = "ack_seq";
+ public static final String CHECK = "check";
+ public static final String WINDOW = "window";
+ public static final String FLAGS = "flags";
+ public static final String TRANSPORT_FIELDS = "transport_fields";
+ public static final String TYPE_TCP = "thtype_tcp";
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng2.kernel.core.event.matching;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.TcpEventStrings;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventMatching.MatchingType;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfNetworkEventMatching.Direction;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfNetworkMatchDefinition;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * Class to match tcp type events. This matching class applies to traces
+ * obtained with the 'addons' lttng module. This module can be obtained with
+ * lttng-modules to generate traces at
+ * https://github.com/giraldeau/lttng-modules/tree/addons
+ *
+ * Note: this module only allows to generate traces to be read and analyzed by
+ * TMF, no code from this module is being used here
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public class TcpEventMatching extends TmfNetworkMatchDefinition {
+
+ @Override
+ public Direction getDirection(ITmfEvent event) {
+ String evname = event.getType().getName();
+ /* Is the event a tcp socket in or out event */
+ if (evname.equals(TcpEventStrings.INET_SOCK_LOCAL_IN)) {
+ return Direction.IN;
+ } else if (evname.equals(TcpEventStrings.INET_SOCK_LOCAL_OUT)) {
+ return Direction.OUT;
+ }
+ return null;
+ }
+
+ /**
+ * The key to uniquely identify a TCP packet depends on many fields. This
+ * method computes the key for a given event.
+ *
+ * @param event
+ * The event for which to compute the key
+ * @return the unique key for this event
+ */
+ @Override
+ public List<Object> getUniqueField(ITmfEvent event) {
+ List<Object> keys = new ArrayList<Object>();
+
+ keys.add(event.getContent().getField(TcpEventStrings.SEQ).getValue());
+ keys.add(event.getContent().getField(TcpEventStrings.ACKSEQ).getValue());
+ keys.add(event.getContent().getField(TcpEventStrings.FLAGS).getValue());
+
+ return keys;
+ }
+
+ @Override
+ public boolean canMatchTrace(ITmfTrace trace) {
+ if (!(trace instanceof CtfTmfTrace)) {
+ return false;
+ }
+ CtfTmfTrace ktrace = (CtfTmfTrace) trace;
+ String[] events = { TcpEventStrings.INET_SOCK_LOCAL_IN, TcpEventStrings.INET_SOCK_LOCAL_OUT };
+ return ktrace.hasAtLeastOneOfEvents(events);
+ }
+
+ @Override
+ public MatchingType[] getApplicableMatchingTypes() {
+ MatchingType[] types = { MatchingType.NETWORK };
+ return types;
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng2.kernel.core.event.matching;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.internal.lttng2.kernel.core.TcpEventStrings;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
+import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventMatching.MatchingType;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfNetworkEventMatching.Direction;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfNetworkMatchDefinition;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * Class to match tcp type events. This class applies to traces obtained with
+ * the full network tracepoint data available from an experimental branch of
+ * lttng-modules. This branch is often rebased on lttng-modules master and is
+ * available at
+ * http://git.dorsal.polymtl.ca/~gbastien?p=lttng-modules.git;a=summary
+ * net_data_experimental branch.
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public class TcpLttngEventMatching extends TmfNetworkMatchDefinition {
+
+ private static final String[] key_seq = { TcpEventStrings.TRANSPORT_FIELDS, TcpEventStrings.TYPE_TCP, TcpEventStrings.SEQ };
+ private static final String[] key_ackseq = { TcpEventStrings.TRANSPORT_FIELDS, TcpEventStrings.TYPE_TCP, TcpEventStrings.ACKSEQ };
+ private static final String[] key_flags = { TcpEventStrings.TRANSPORT_FIELDS, TcpEventStrings.TYPE_TCP, TcpEventStrings.FLAGS };
+
+ private static boolean canMatchPacket(final ITmfEvent event) {
+ TmfEventField field = (TmfEventField) event.getContent();
+
+ String[] tcp_data = { TcpEventStrings.TRANSPORT_FIELDS, TcpEventStrings.TYPE_TCP };
+ ITmfEventField data = field.getSubField(tcp_data);
+ if (data != null) {
+ return (data.getValue() != null);
+ }
+ return false;
+ }
+
+ /**
+ * The key to uniquely identify a TCP packet depends on many fields. This
+ * method computes the key for a given event.
+ *
+ * @param event
+ * The event for which to compute the key
+ * @return the unique key for this event
+ */
+ @Override
+ public List<Object> getUniqueField(ITmfEvent event) {
+ List<Object> keys = new ArrayList<Object>();
+
+ TmfEventField field = (TmfEventField) event.getContent();
+ ITmfEventField data;
+
+ data = field.getSubField(key_seq);
+ if (data != null) {
+ keys.add(data.getValue());
+ }
+ data = field.getSubField(key_ackseq);
+ if (data != null) {
+ keys.add(data.getValue());
+ }
+ data = field.getSubField(key_flags);
+ if (data != null) {
+ keys.add(data.getValue());
+ }
+
+ return keys;
+ }
+
+ @Override
+ public boolean canMatchTrace(ITmfTrace trace) {
+ if (!(trace instanceof CtfTmfTrace)) {
+ return false;
+ }
+ CtfTmfTrace ktrace = (CtfTmfTrace) trace;
+ String[] events = { TcpEventStrings.NET_DEV_QUEUE, TcpEventStrings.NETIF_RECEIVE_SKB };
+ return (ktrace.hasAtLeastOneOfEvents(events));
+ }
+
+ @Override
+ public Direction getDirection(ITmfEvent event) {
+ String evname = event.getType().getName();
+
+ /* Is the event a tcp socket in or out event */
+ if (evname.equals(TcpEventStrings.NETIF_RECEIVE_SKB) && canMatchPacket(event)) {
+ return Direction.IN;
+ } else if (evname.equals(TcpEventStrings.NET_DEV_QUEUE) && canMatchPacket(event)) {
+ return Direction.OUT;
+ }
+ return null;
+ }
+
+ @Override
+ public MatchingType[] getApplicableMatchingTypes() {
+ MatchingType[] types = { MatchingType.NETWORK };
+ return types;
+ }
+
+}
return validStatus;
}
+ /**
+ * @since 3.0
+ */
@Override
- protected void buildStateSystem() throws TmfTraceException {
+ protected IStatus buildStateSystem() {
super.buildStateSystem();
/* Build the state system specific to LTTng kernel traces */
final File htFile = new File(directory + HISTORY_TREE_FILE_NAME);
final ITmfStateProvider htInput = new LttngKernelStateProvider(this);
- ITmfStateSystem ss = TmfStateSystemFactory.newFullHistory(htFile, htInput, false);
- fStateSystems.put(STATE_ID, ss);
+ try {
+ ITmfStateSystem ss = TmfStateSystemFactory.newFullHistory(htFile, htInput, false);
+ fStateSystems.put(STATE_ID, ss);
+ } catch (TmfTraceException e) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
+ }
+ return Status.OK_STATUS;
}
}
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.lttng2.kernel.ui.tests;singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.junit;bundle-version="4.0.0",
org.eclipse.core.runtime,
org.eclipse.ui,
- org.eclipse.linuxtools.lttng2.kernel.ui;bundle-version="2.1.0"
+ org.eclipse.linuxtools.lttng2.kernel.ui;bundle-version="3.0.0"
Export-Package: org.eclipse.linuxtools.lttng2.kernel.ui.tests
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng2.kernel.ui.tests</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<name>Linux Tools LTTng Kernel Analysis UI Tests Plug-in</name>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.lttng2.kernel.ui;singleton:=true
Bundle-Activator: org.eclipse.linuxtools.internal.lttng2.kernel.ui.Activator
org.eclipse.ui.ide,
org.eclipse.core.resources,
org.eclipse.core.runtime,
- org.eclipse.linuxtools.tmf.core;bundle-version="2.1.0",
- org.eclipse.linuxtools.tmf.ui;bundle-version="2.1.0",
- org.eclipse.linuxtools.lttng2.core;bundle-version="2.1.0",
- org.eclipse.linuxtools.lttng2.ui;bundle-version="2.1.0",
- org.eclipse.linuxtools.lttng2.kernel.core;bundle-version="2.1.0"
+ org.eclipse.linuxtools.tmf.core;bundle-version="3.0.0",
+ org.eclipse.linuxtools.tmf.ui;bundle-version="3.0.0",
+ org.eclipse.linuxtools.lttng2.core;bundle-version="3.0.0",
+ org.eclipse.linuxtools.lttng2.ui;bundle-version="3.0.0",
+ org.eclipse.linuxtools.lttng2.kernel.core;bundle-version="3.0.0"
Export-Package: org.eclipse.linuxtools.internal.lttng2.kernel.ui;x-friends:="org.eclipse.linuxtools.lttng2.kernel.ui.tests",
org.eclipse.linuxtools.internal.lttng2.kernel.ui.viewers.events;x-internal:=true,
org.eclipse.linuxtools.internal.lttng2.kernel.ui.views;x-internal:=true,
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng2.kernel.ui</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools LTTng Kernel Analysis UI Plug-in</name>
<feature
id="org.eclipse.linuxtools.lttng2.kernel"
label="%featureName"
- version="2.1.0.qualifier"
+ version="3.0.0.qualifier"
provider-name="%featureProvider"
license-feature="org.eclipse.linuxtools.license.feature"
license-feature-version="1.0.0.qualifier">
<requires>
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.linuxtools.ctf.core" version="2.1.0" match="greaterOrEqual"/>
- <import plugin="org.eclipse.linuxtools.tmf.core" version="2.1.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.ctf.core" version="3.0.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.tmf.core" version="3.0.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.ui"/>
<import plugin="org.eclipse.ui.ide"/>
- <import plugin="org.eclipse.linuxtools.tmf.ui" version="2.1.0" match="greaterOrEqual"/>
- <import plugin="org.eclipse.linuxtools.lttng2.core" version="2.1.0" match="greaterOrEqual"/>
- <import plugin="org.eclipse.linuxtools.lttng2.ui" version="2.1.0" match="greaterOrEqual"/>
- <import plugin="org.eclipse.linuxtools.lttng2.kernel.core" version="2.1.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.tmf.ui" version="3.0.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.lttng2.core" version="3.0.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.lttng2.ui" version="3.0.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.lttng2.kernel.core" version="3.0.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.help"/>
</requires>
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng2.kernel</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
<name>Linux Tools LTTng Kernel Analysis Feature</name>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.lttng2.ui.tests;singleton:=true
Bundle-ActivationPolicy: lazy
org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.ui.ide,
- org.eclipse.linuxtools.lttng2.core;bundle-version="2.1.0",
- org.eclipse.linuxtools.lttng2.ui;bundle-version="2.1.0"
+ org.eclipse.linuxtools.lttng2.core;bundle-version="3.0.0",
+ org.eclipse.linuxtools.lttng2.ui;bundle-version="3.0.0"
Import-Package: org.eclipse.rse.core,
org.eclipse.rse.core.model,
org.eclipse.rse.core.subsystems,
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng2.ui.tests</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<name>Linux Tools LTTng UI Tests Plug-in</name>
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.lttng2.ui;singleton:=true
Bundle-Activator: org.eclipse.linuxtools.internal.lttng2.ui.Activator
org.eclipse.ui.ide,
org.eclipse.core.resources,
org.eclipse.core.runtime,
- org.eclipse.linuxtools.lttng2.core;bundle-version="2.1.0",
- org.eclipse.linuxtools.tmf.core;bundle-version="2.1.0",
- org.eclipse.linuxtools.tmf.ui;bundle-version="2.1.0"
+ org.eclipse.linuxtools.lttng2.core;bundle-version="3.0.0",
+ org.eclipse.linuxtools.tmf.core;bundle-version="3.0.0",
+ org.eclipse.linuxtools.tmf.ui;bundle-version="3.0.0"
Export-Package: org.eclipse.linuxtools.internal.lttng2.ui;x-friends:="org.eclipse.linuxtools.lttng2.ui.tests",
org.eclipse.linuxtools.internal.lttng2.ui.views.control;x-friends:="org.eclipse.linuxtools.lttng2.kernel.ui,org.eclipse.linuxtools.lttng2.ui.tests",
org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;x-friends:="org.eclipse.linuxtools.lttng2.ui.tests",
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng2.ui</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools LTTng UI Plug-in</name>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.lttng2.ust.core.tests;singleton:=true
Bundle-ActivationPolicy: lazy
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng2.ust.core.tests</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<name>Linux Tools LTTng Userspace Tracer Analysis Core Test Plug-in</name>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.lttng2.ust.core;singleton:=true
Bundle-Activator: org.eclipse.linuxtools.internal.lttng2.ust.core.Activator
org.eclipse.linuxtools.lttng2.ust.core.trace
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
- org.eclipse.linuxtools.ctf.core;bundle-version="2.1.0",
- org.eclipse.linuxtools.tmf.core;bundle-version="2.1.0"
+ org.eclipse.linuxtools.ctf.core;bundle-version="3.0.0",
+ org.eclipse.linuxtools.tmf.core;bundle-version="3.0.0"
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng2.ust.core</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools LTTng Userspace Tracer Analysis Core Plug-in</name>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.lttng2.ust.ui.tests;singleton:=true
Bundle-ActivationPolicy: lazy
org.eclipse.ui,
org.eclipse.core.resources,
org.eclipse.core.runtime,
- org.eclipse.linuxtools.lttng2.ust.ui;bundle-version="2.1.0"
+ org.eclipse.linuxtools.lttng2.ust.ui;bundle-version="3.0.0"
Export-Package: org.eclipse.linuxtools.lttng2.ust.ui.tests
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng2.ust.ui.tests</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<name>Linux Tools LTTng Userspace Tracer Analysis UI Tests Plug-in</name>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.lttng2.ust.ui;singleton:=true
Bundle-Activator: org.eclipse.linuxtools.internal.lttng2.ust.ui.Activator
Require-Bundle: org.eclipse.core.resources,
org.eclipse.core.runtime,
org.eclipse.ui,
- org.eclipse.linuxtools.lttng2.ust.core;bundle-version="2.1.0",
- org.eclipse.linuxtools.tmf.core;bundle-version="2.1.0"
+ org.eclipse.linuxtools.lttng2.ust.core;bundle-version="3.0.0",
+ org.eclipse.linuxtools.tmf.core;bundle-version="3.0.0"
Export-Package: org.eclipse.linuxtools.internal.lttng2.ust.ui;x-friends:="org.eclipse.linuxtools.lttng2.ust.ui.tests"
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng2.ust.ui</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools LTTng Userspace Tracer Analysis UI Plug-in</name>
<feature
id="org.eclipse.linuxtools.lttng2.ust"
label="%featureName"
- version="2.1.0.qualifier"
+ version="3.0.0.qualifier"
provider-name="%featureProvider"
license-feature="org.eclipse.linuxtools.license.feature"
license-feature-version="1.0.0.qualifier">
<requires>
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.linuxtools.ctf.core" version="2.1.0" match="greaterOrEqual"/>
- <import plugin="org.eclipse.linuxtools.tmf.core" version="2.1.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.ctf.core" version="3.0.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.tmf.core" version="3.0.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.ui"/>
<import plugin="org.eclipse.ui.ide"/>
- <import plugin="org.eclipse.linuxtools.tmf.ui" version="2.1.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.tmf.ui" version="3.0.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.help"/>
</requires>
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng2.ust</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
<name>Linux Tools LTTng Userspace Tracer Analysis Feature</name>
<feature
id="org.eclipse.linuxtools.lttng2"
label="%featureName"
- version="2.1.0.qualifier"
+ version="3.0.0.qualifier"
provider-name="%featureProvider"
license-feature="org.eclipse.linuxtools.license.feature"
license-feature-version="1.0.0.qualifier">
<import plugin="org.eclipse.ui"/>
<import plugin="org.eclipse.ui.ide"/>
<import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.linuxtools.lttng2.core" version="2.0.0" match="greaterOrEqual"/>
- <import plugin="org.eclipse.linuxtools.tmf.core" version="2.0.0" match="greaterOrEqual"/>
- <import plugin="org.eclipse.linuxtools.tmf.ui" version="2.0.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.lttng2.core" version="3.0.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.tmf.core" version="3.0.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.tmf.ui" version="3.0.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.help"/>
<import feature="org.eclipse.rse" version="3.1.100" match="greaterOrEqual"/>
</requires>
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.lttng2</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
<name>Linux Tools LTTng (Linux Tracing Toolkit) Feature</name>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.tmf.core.tests;singleton:=true
Bundle-Activator: org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin
Require-Bundle: org.junit;bundle-version="4.0.0",
org.eclipse.core.runtime,
org.eclipse.core.resources,
- org.eclipse.linuxtools.tmf.core;bundle-version="2.1.0",
- org.eclipse.linuxtools.ctf.core;bundle-version="2.1.0",
- org.eclipse.linuxtools.ctf.core.tests;bundle-version="2.1.0"
+ org.eclipse.linuxtools.tmf.core;bundle-version="3.0.0",
+ org.eclipse.linuxtools.ctf.core;bundle-version="3.0.0",
+ org.eclipse.linuxtools.ctf.core.tests;bundle-version="3.0.0"
Export-Package: org.eclipse.linuxtools.tmf.core.tests,
org.eclipse.linuxtools.tmf.core.tests.shared,
org.eclipse.linuxtools.tmf.tests.stubs.trace;x-friends:="org.eclipse.linuxtools.tmf.ui.tests"
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.tmf.core.tests</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<name>Linux Tools TMF Core Tests Plug-in</name>
private static final File emptyFile = new File("");
private static CtfTmfTrace emptyTrace = new CtfTmfTrace();
- private static CtfTmfTrace[] testTraces = new CtfTmfTrace[3];
+ private static CtfTmfTrace[] testTraces = new CtfTmfTrace[5];
/**
* Get an empty File (new File("");)
org.eclipse.linuxtools.tmf.core.tests.signal.AllTests.class,
org.eclipse.linuxtools.tmf.core.tests.statesystem.AllTests.class,
org.eclipse.linuxtools.tmf.core.tests.statistics.AllTests.class,
+ org.eclipse.linuxtools.tmf.core.tests.synchronization.AllTests.class,
org.eclipse.linuxtools.tmf.core.tests.trace.AllTests.class,
+ org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint.AllTests.class,
+ org.eclipse.linuxtools.tmf.core.tests.trace.location.AllTests.class,
org.eclipse.linuxtools.tmf.core.tests.uml2sd.AllTests.class,
org.eclipse.linuxtools.tmf.core.tests.util.AllTests.class
})
import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfStartSynchSignal;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
*/
@Test
public void testGetPlainEvents() {
- final int BLOCK_SIZE = 100;
final int NB_EVENTS = 1000;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
ITmfDataProvider provider = eventProviders[0];
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
+ final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
+ range, 0, NB_EVENTS, ExecutionType.FOREGROUND) {
@Override
public void handleData(ITmfEvent event) {
super.handleData(event);
*/
@Test
public void testCancelRequests() {
-
- final int BLOCK_SIZE = 100;
final int NB_EVENTS = 1000;
final int NUMBER_EVENTS_BEFORE_CANCEL_REQ1 = 10;
final int NUMBER_EVENTS_BEFORE_CANCEL_REQ2 = 800;
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
// Create first request
- final TmfEventRequest request1 = new TmfEventRequest(ITmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
+ final TmfEventRequest request1 = new TmfEventRequest(ITmfEvent.class,
+ range, 0, NB_EVENTS, ExecutionType.FOREGROUND) {
@Override
public void handleData(ITmfEvent event) {
super.handleData(event);
assertFalse("isRunning", request1.isRunning());
// Create second request
- final TmfEventRequest request2 = new TmfEventRequest(ITmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
+ final TmfEventRequest request2 = new TmfEventRequest(ITmfEvent.class,
+ range, 0, NB_EVENTS, ExecutionType.FOREGROUND) {
@Override
public void handleData(ITmfEvent event) {
super.handleData(event);
}
private static void getSyntheticData(final TmfTimeRange range,
- final int nbEvents, final int blockSize) throws InterruptedException {
+ final int nbEvents) throws InterruptedException {
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
ITmfDataProvider provider = eventProviders[0];
final TmfEventRequest request = new TmfEventRequest(TmfSyntheticEventStub.class, range,
- nbEvents, blockSize) {
+ 0, nbEvents, ExecutionType.FOREGROUND) {
@Override
public void handleData(ITmfEvent event) {
super.handleData(event);
public void testGetSyntheticEvents_EqualBlockSizes() {
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
try {
- getSyntheticData(range, 1000, TmfSyntheticEventProviderStub.BLOCK_SIZE);
- } catch (InterruptedException e) {
- fail();
- }
- }
-
- /**
- * Test getSyntheticEvents for smaller block sizes.
- */
- @Test
- public void testGetSyntheticEvents_SmallerBlock() {
- TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- try {
- getSyntheticData(range, 1000, TmfSyntheticEventProviderStub.BLOCK_SIZE / 2);
- } catch (InterruptedException e) {
- fail();
- }
- }
-
- /**
- * Test getSyntheticEvents for larger block sizes.
- */
- @Test
- public void testGetSyntheticEvents_LargerBlock() {
- TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- try {
- getSyntheticData(range, 1000, TmfSyntheticEventProviderStub.BLOCK_SIZE * 2);
+ getSyntheticData(range, 1000);
} catch (InterruptedException e) {
fail();
}
TmfTimestamp end = new TmfTimestamp(1000, (byte) -3, 0);
TmfTimeRange range = new TmfTimeRange(start, end);
try {
- getSyntheticData(range, -1, TmfSyntheticEventProviderStub.BLOCK_SIZE);
+ getSyntheticData(range, -1);
} catch (InterruptedException e) {
fail();
}
CtfTmfEventField result = CtfTmfEventField.parseField(fieldDef, NAME);
assertEquals("test=float=9.551467814359616E-38", result.toString());
}
-
- /**
- * Run the CtfTmfEventField formatNumber(Long, int, boolean) method test for
- * unsigned values.
- */
- @Test
- public void testFormatNumber_unsignedLong() {
-
- long unsignedLongValue = -64;
- String result = CtfTmfEventField.formatNumber(unsignedLongValue, 10, false);
- // -64 + 2^64 = 18446744073709551552
- assertEquals("18446744073709551552", result);
-
- unsignedLongValue = -131940199973272L;
- result = CtfTmfEventField.formatNumber(unsignedLongValue, 10, false);
- // -131940199973272l + 2^64 = 18446612133509578344
- assertEquals("18446612133509578344", result);
-
- unsignedLongValue = 123456789L;
- result = CtfTmfEventField.formatNumber(unsignedLongValue, 10, false);
- assertEquals("123456789", result);
- }
-
- /**
- * Run the CtfTmfEventField formatNumber(Long, int, boolean) method test for
- * signed values.
- */
- @Test
- public void testFormatNumber_signedLong() {
- long signedValue = -64L;
- String result = CtfTmfEventField.formatNumber(signedValue, 10, true);
- assertEquals("-64", result);
-
- signedValue = -131940199973272L;
- result = CtfTmfEventField.formatNumber(signedValue, 10, true);
- assertEquals("-131940199973272", result);
-
- signedValue = 123456789L;
- result = CtfTmfEventField.formatNumber(signedValue, 10, true);
- assertEquals("123456789", result);
- }
}
assertArrayEquals(fields2, fields);
}
+ /**
+ * Run the ITmfEventField getSubFieldValue(String[]) method test.
+ */
+ @Test
+ public void testGetSubFieldValue() {
+ /* Field exists */
+ String[] names = { "pid" };
+ assertNotNull(fixture.getContent().getSubField(names));
+
+ /* First field exists, not the second */
+ String[] names2 = { "pid", "abcd" };
+ assertNull(fixture.getContent().getSubField(names2));
+
+ /* Both field do not exist */
+ String[] names3 = { "pfid", "abcd" };
+ assertNull(fixture.getContent().getSubField(names3));
+
+ /* TODO Missing case of embedded field, need event for it */
+ }
+
/**
* Run the long getID() method test.
*/
assertTrue(fixture.hasAtLeastOneOfEvents(names));
assertFalse(fixture.hasAllEvents(names));
}
+
+ /**
+ * Run the String getHostId() method test
+ */
+ @Test
+ public void testCtfHostId() {
+ String a = fixture.getHostId();
+ assertEquals("\"84db105b-b3f4-4821-b662-efc51455106a\"", a);
+ }
+
}
public EventContextTestRequest(long timestamp) {
super(CtfTmfEvent.class,
new TmfTimeRange(new CtfTmfTimestamp(timestamp), TmfTimestamp.BIG_CRUNCH),
- 0, 1, 1, ExecutionType.FOREGROUND);
+ 0, 1, ExecutionType.FOREGROUND);
}
@Override
private RequestBenchmark(final Class<? extends ITmfEvent> dataType,
final TmfTimeRange range, final int nbRequested) {
- super(dataType, range, nbRequested, 1);
+ super(dataType, range, 0, nbRequested, ExecutionType.FOREGROUND);
}
// Path of the trace
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
final File test = new File(FileLocator.toFileURL(location).toURI());
- trace = new TmfTraceStub(test.toURI().getPath(), 500, false);
+ trace = new TmfTraceStub(test.toURI().getPath(), 500, false, null, null);
} catch (final TmfTraceException e) {
e.printStackTrace();
} catch (final URISyntaxException e) {
import org.eclipse.linuxtools.internal.tmf.core.request.TmfCoalescedDataRequest;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.tests.stubs.request.TmfDataRequestStub;
import org.junit.Before;
import org.junit.Test;
@Before
public void setUp() {
TmfDataRequest.reset();
- fRequest1 = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, 200);
- fRequest2 = new TmfCoalescedDataRequest(ITmfEvent.class, 20, 100, 200);
- fRequest3 = new TmfCoalescedDataRequest(ITmfEvent.class, 20, 200, 200);
- fRequest4 = new TmfCoalescedDataRequest(ITmfEvent.class, 20, 200, 300);
+ fRequest1 = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
+ fRequest2 = new TmfCoalescedDataRequest(ITmfEvent.class, 20, 100, ExecutionType.FOREGROUND);
+ fRequest3 = new TmfCoalescedDataRequest(ITmfEvent.class, 20, 200, ExecutionType.FOREGROUND);
+ fRequest4 = new TmfCoalescedDataRequest(ITmfEvent.class, 20, 200, ExecutionType.FOREGROUND);
- fRequest1b = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, 200);
- fRequest1c = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, 200);
+ fRequest1b = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
+ fRequest1c = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
fRequestCount = fRequest1c.getRequestId() + 1;
}
private static TmfCoalescedDataRequest setupTestRequest(final boolean[] flags) {
- TmfCoalescedDataRequest request = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, 200) {
+ TmfCoalescedDataRequest request = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND) {
@Override
public void handleCompleted() {
super.handleCompleted();
}
// ------------------------------------------------------------------------
- // Constructors
+ // Constructor
// ------------------------------------------------------------------------
- @Test
- public void testTmfCoalescedDataRequest() {
- TmfCoalescedDataRequest request = new TmfCoalescedDataRequest(ITmfEvent.class);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("getIndex", 0, request.getIndex());
- assertEquals("getNbRequestedEvents", TmfDataRequest.ALL_DATA, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
- @Test
- public void testTmfCoalescedDataRequestIndex() {
- TmfCoalescedDataRequest request = new TmfCoalescedDataRequest(ITmfEvent.class, 10);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("getIndex", 10, request.getIndex());
- assertEquals("getNbRequestedEvents", TmfDataRequest.ALL_DATA, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
- @Test
- public void testTmfCoalescedDataRequestIndexNbRequested() {
- TmfCoalescedDataRequest request = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("getIndex", 10, request.getIndex());
- assertEquals("getNbRequestedEvents", 100, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
@Test
public void testTmfCoalescedDataRequestIndexNbEventsBlocksize() {
- TmfCoalescedDataRequest request = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, 200);
+ TmfCoalescedDataRequest request = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
assertEquals("getRequestId", fRequestCount++, request.getRequestId());
assertEquals("getDataType", ITmfEvent.class, request.getDataType());
@Test
public void testToString() {
- String expected1 = "[TmfCoalescedDataRequest(0,ITmfEvent,FOREGROUND,10,100,200, [])]";
- String expected2 = "[TmfCoalescedDataRequest(1,ITmfEvent,FOREGROUND,20,100,200, [])]";
- String expected3 = "[TmfCoalescedDataRequest(2,ITmfEvent,FOREGROUND,20,200,200, [])]";
- String expected4 = "[TmfCoalescedDataRequest(3,ITmfEvent,FOREGROUND,20,200,300, [])]";
+ String expected1 = "[TmfCoalescedDataRequest(0,ITmfEvent,FOREGROUND,10,100, [])]";
+ String expected2 = "[TmfCoalescedDataRequest(1,ITmfEvent,FOREGROUND,20,100, [])]";
+ String expected3 = "[TmfCoalescedDataRequest(2,ITmfEvent,FOREGROUND,20,200, [])]";
+ String expected4 = "[TmfCoalescedDataRequest(3,ITmfEvent,FOREGROUND,20,200, [])]";
assertEquals("toString", expected1, fRequest1.toString());
assertEquals("toString", expected2, fRequest2.toString());
@Test
public void testIsCompatible() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, 200);
- TmfDataRequest request1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100, 200);
- TmfDataRequest request2 = new TmfDataRequestStub(ITmfEvent.class, 5, 100, 200);
- TmfDataRequest request3 = new TmfDataRequestStub(ITmfEvent.class, 5, 4, 200);
- TmfDataRequest request4 = new TmfDataRequestStub(ITmfEvent.class, 5, 5, 200);
- TmfDataRequest request5 = new TmfDataRequestStub(ITmfEvent.class, 15, 100, 200);
- TmfDataRequest request6 = new TmfDataRequestStub(ITmfEvent.class, 100, 100, 200);
- TmfDataRequest request7 = new TmfDataRequestStub(ITmfEvent.class, 110, 100, 200);
- TmfDataRequest request8 = new TmfDataRequestStub(ITmfEvent.class, 111, 100, 200);
+ TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
+ TmfDataRequest request1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
+ TmfDataRequest request2 = new TmfDataRequestStub(ITmfEvent.class, 5, 100);
+ TmfDataRequest request3 = new TmfDataRequestStub(ITmfEvent.class, 5, 4);
+ TmfDataRequest request4 = new TmfDataRequestStub(ITmfEvent.class, 5, 5);
+ TmfDataRequest request5 = new TmfDataRequestStub(ITmfEvent.class, 15, 100);
+ TmfDataRequest request6 = new TmfDataRequestStub(ITmfEvent.class, 100, 100);
+ TmfDataRequest request7 = new TmfDataRequestStub(ITmfEvent.class, 110, 100);
+ TmfDataRequest request8 = new TmfDataRequestStub(ITmfEvent.class, 111, 100);
assertTrue("isCompatible", coalescedRequest.isCompatible(request1));
assertTrue("isCompatible", coalescedRequest.isCompatible(request2));
assertTrue("isCompatible", coalescedRequest.isCompatible(request7));
assertTrue("isCompatible", coalescedRequest.isCompatible(request8));
- TmfDataRequest request9 = new TmfDataRequestStub(ITmfEvent.class, 5, 3, 200);
- TmfDataRequest request10 = new TmfDataRequestStub(ITmfEvent.class, 112, 100, 200);
+ TmfDataRequest request9 = new TmfDataRequestStub(ITmfEvent.class, 5, 3);
+ TmfDataRequest request10 = new TmfDataRequestStub(ITmfEvent.class, 112, 100);
assertFalse("isCompatible", coalescedRequest.isCompatible(request9));
assertFalse("isCompatible", coalescedRequest.isCompatible(request10));
@Test
public void testAddRequest1() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, 200);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 10, 100, 200);
+ TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
+ TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
assertTrue("isCompatible", coalescedRequest.isCompatible(request));
coalescedRequest.addRequest(request);
assertEquals("addRequest", 10, coalescedRequest.getIndex());
assertEquals("addRequest", 100, coalescedRequest.getNbRequested());
- assertEquals("addRequest", 200, coalescedRequest.getBlockSize());
}
@Test
public void testAddRequest2() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, 200);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 5, 100, 200);
+ TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
+ TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 5, 100);
assertTrue("isCompatible", coalescedRequest.isCompatible(request));
coalescedRequest.addRequest(request);
assertEquals("addRequest", 5, coalescedRequest.getIndex());
assertEquals("addRequest", 105, coalescedRequest.getNbRequested());
- assertEquals("addRequest", 200, coalescedRequest.getBlockSize());
}
@Test
public void testAddRequest3() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, 200);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 5, 4, 200);
+ TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
+ TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 5, 4);
assertTrue("isCompatible", coalescedRequest.isCompatible(request));
coalescedRequest.addRequest(request);
assertEquals("addRequest", 5, coalescedRequest.getIndex());
assertEquals("addRequest", 105, coalescedRequest.getNbRequested());
- assertEquals("addRequest", 200, coalescedRequest.getBlockSize());
}
@Test
public void testAddRequest4() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, 200);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 5, 5, 200);
+ TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
+ TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 5, 5);
assertTrue("isCompatible", coalescedRequest.isCompatible(request));
coalescedRequest.addRequest(request);
assertEquals("addRequest", 5, coalescedRequest.getIndex());
assertEquals("addRequest", 105, coalescedRequest.getNbRequested());
- assertEquals("addRequest", 200, coalescedRequest.getBlockSize());
}
@Test
public void testAddRequest5() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, 200);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 15, 100, 200);
+ TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
+ TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 15, 100);
assertTrue("isCompatible", coalescedRequest.isCompatible(request));
coalescedRequest.addRequest(request);
assertEquals("addRequest", 10, coalescedRequest.getIndex());
assertEquals("addRequest", 105, coalescedRequest.getNbRequested());
- assertEquals("addRequest", 200, coalescedRequest.getBlockSize());
}
@Test
public void testAddRequest6() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, 200);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 100, 100, 200);
+ TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
+ TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 100, 100);
assertTrue("isCompatible", coalescedRequest.isCompatible(request));
coalescedRequest.addRequest(request);
assertEquals("addRequest", 10, coalescedRequest.getIndex());
assertEquals("addRequest", 190, coalescedRequest.getNbRequested());
- assertEquals("addRequest", 200, coalescedRequest.getBlockSize());
}
@Test
public void testAddRequest7() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, 200);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 110, 100, 200);
+ TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
+ TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 110, 100);
assertTrue("isCompatible", coalescedRequest.isCompatible(request));
coalescedRequest.addRequest(request);
assertEquals("addRequest", 10, coalescedRequest.getIndex());
assertEquals("addRequest", 200, coalescedRequest.getNbRequested());
- assertEquals("addRequest", 200, coalescedRequest.getBlockSize());
}
@Test
public void testAddRequest8() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, 200);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 111, 100, 200);
+ TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
+ TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 111, 100);
assertTrue("isCompatible", coalescedRequest.isCompatible(request));
coalescedRequest.addRequest(request);
assertEquals("addRequest", 10, coalescedRequest.getIndex());
assertEquals("addRequest", 201, coalescedRequest.getNbRequested());
- assertEquals("addRequest", 200, coalescedRequest.getBlockSize());
}
// ------------------------------------------------------------------------
// Test request
final boolean[] crFlags = new boolean[4];
TmfCoalescedDataRequest request = setupTestRequest(crFlags);
- TmfDataRequest subRequest1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100, 200);
- TmfDataRequest subRequest2 = new TmfDataRequestStub(ITmfEvent.class, 10, 100, 200);
+ TmfDataRequest subRequest1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
+ TmfDataRequest subRequest2 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
request.addRequest(subRequest1);
request.addRequest(subRequest2);
public void testFail() {
final boolean[] crFlags = new boolean[4];
TmfCoalescedDataRequest request = setupTestRequest(crFlags);
- TmfDataRequest subRequest1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100, 200);
- TmfDataRequest subRequest2 = new TmfDataRequestStub(ITmfEvent.class, 10, 100, 200);
+ TmfDataRequest subRequest1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
+ TmfDataRequest subRequest2 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
request.addRequest(subRequest1);
request.addRequest(subRequest2);
public void testCancel() {
final boolean[] crFlags = new boolean[4];
TmfCoalescedDataRequest request = setupTestRequest(crFlags);
- TmfDataRequest subRequest1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100, 200);
- TmfDataRequest subRequest2 = new TmfDataRequestStub(ITmfEvent.class, 10, 100, 200);
+ TmfDataRequest subRequest1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
+ TmfDataRequest subRequest2 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
request.addRequest(subRequest1);
request.addRequest(subRequest2);
public void testCancelSubRequests() {
final boolean[] crFlags = new boolean[4];
TmfCoalescedDataRequest request = setupTestRequest(crFlags);
- TmfDataRequest subRequest1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100, 200);
- TmfDataRequest subRequest2 = new TmfDataRequestStub(ITmfEvent.class, 10, 100, 200);
+ TmfDataRequest subRequest1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
+ TmfDataRequest subRequest2 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
request.addRequest(subRequest1);
request.addRequest(subRequest2);
@Before
public void setUp() {
TmfDataRequest.reset();
- fRequest1 = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 100, 200);
- fRequest2 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 100, 200);
- fRequest3 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 200, 200);
- fRequest4 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 200, 300);
+ fRequest1 = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND);
+ fRequest2 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 0, 100, ExecutionType.FOREGROUND);
+ fRequest3 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 0, 200, ExecutionType.FOREGROUND);
+ fRequest4 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 0, 200, ExecutionType.FOREGROUND);
- fRequest1b = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 100, 200);
- fRequest1c = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 100, 200);
+ fRequest1b = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND);
+ fRequest1c = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND);
fRequestCount = fRequest1c.getRequestId() + 1;
}
private TmfCoalescedEventRequest setupTestRequest(final boolean[] flags) {
- TmfCoalescedEventRequest request = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 100, 200) {
+ TmfCoalescedEventRequest request = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND) {
@Override
public void handleCompleted() {
super.handleCompleted();
}
// ------------------------------------------------------------------------
- // Constructors
+ // Constructor
// ------------------------------------------------------------------------
- @Test
- public void testTmfCoalescedEventRequest() {
- TmfCoalescedEventRequest request = new TmfCoalescedEventRequest(ITmfEvent.class);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("getRange", range1, request.getRange());
- assertEquals("getNbRequestedEvents", TmfDataRequest.ALL_DATA, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
- @Test
- public void testTmfCoalescedEventRequestIndex() {
- TmfCoalescedEventRequest request = new TmfCoalescedEventRequest(ITmfEvent.class, range1);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("getRange", range1, request.getRange());
- assertEquals("getNbRequestedEvents", TmfDataRequest.ALL_DATA, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
- public void testTmfCoalescedEventRequestIndexNbRequested() {
- TmfCoalescedEventRequest request = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 100);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("getRange", range1, request.getRange());
- assertEquals("getNbRequestedEvents", 100, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
@Test
public void testTmfCoalescedEventRequestIndexNbEventsBlocksize() {
- TmfCoalescedEventRequest request = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 100, 200);
+ TmfCoalescedEventRequest request = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND);
assertEquals("getRequestId", fRequestCount++, request.getRequestId());
assertEquals("getDataType", ITmfEvent.class, request.getDataType());
@Test
public void testEqualsSuper() {
TmfCoalescedDataRequest dataRequest1 = new TmfCoalescedDataRequest(
- fRequest1.getDataType(), fRequest1.getIndex(), fRequest1.getNbRequested());
+ fRequest1.getDataType(),
+ fRequest1.getIndex(),
+ fRequest1.getNbRequested(),
+ ExecutionType.FOREGROUND);
TmfCoalescedDataRequest dataRequest2 = new TmfCoalescedDataRequest(
- fRequest1.getDataType(), fRequest1.getIndex(), fRequest1.getNbRequested());
+ fRequest1.getDataType(),
+ fRequest1.getIndex(),
+ fRequest1.getNbRequested(),
+ ExecutionType.FOREGROUND);
TmfCoalescedDataRequest dataRequest3 = new TmfCoalescedDataRequest(
- fRequest3.getDataType(), fRequest3.getIndex(), fRequest3.getNbRequested());
+ fRequest3.getDataType(),
+ fRequest3.getIndex(),
+ fRequest3.getNbRequested(),
+ ExecutionType.FOREGROUND);
assertTrue("equals", fRequest1.equals(dataRequest2));
assertTrue("equals", fRequest2.equals(dataRequest1));
@Test
public void testToString() {
- String expected1 = "[TmfCoalescedEventRequest(0,ITmfEvent,FOREGROUND," + range1 + ",0,100,200, [])]";
- String expected2 = "[TmfCoalescedEventRequest(1,ITmfEvent,FOREGROUND," + range2 + ",0,100,200, [])]";
- String expected3 = "[TmfCoalescedEventRequest(2,ITmfEvent,FOREGROUND," + range2 + ",0,200,200, [])]";
- String expected4 = "[TmfCoalescedEventRequest(3,ITmfEvent,FOREGROUND," + range2 + ",0,200,300, [])]";
+ String expected1 = "[TmfCoalescedEventRequest(0,ITmfEvent,FOREGROUND," + range1 + ",0,100, [])]";
+ String expected2 = "[TmfCoalescedEventRequest(1,ITmfEvent,FOREGROUND," + range2 + ",0,100, [])]";
+ String expected3 = "[TmfCoalescedEventRequest(2,ITmfEvent,FOREGROUND," + range2 + ",0,200, [])]";
+ String expected4 = "[TmfCoalescedEventRequest(3,ITmfEvent,FOREGROUND," + range2 + ",0,200, [])]";
assertEquals("toString", expected1, fRequest1.toString());
assertEquals("toString", expected2, fRequest2.toString());
@Test
public void testIsCompatible() {
- TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 100, 200);
+ TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND);
TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range2, 100, 200);
TmfEventRequest req3 = new TmfEventRequestStub(ITmfEvent.class, range1, 101, 200);
@Test
public void testAddEvent1() {
- TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 2147483647, 200, ExecutionType.FOREGROUND);
+ TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 2147483647, ExecutionType.FOREGROUND);
TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 0, 2147483647, 200);
TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range1, 1, 2147483647, 200);
assertEquals("addRequest", 0, coalescedRequest.getIndex());
assertEquals("addRequest", 2147483647, coalescedRequest.getNbRequested());
- assertEquals("addRequest", 200, coalescedRequest.getBlockSize());
-
}
@Test
public void testAddEvent2() {
- TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 1, 2147483647, 200, ExecutionType.FOREGROUND);
+ TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 1, 2147483647, ExecutionType.FOREGROUND);
TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 1, 2147483647, 200);
TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range1, 0, 2147483647, 200);
assertEquals("addRequest", 0, coalescedRequest.getIndex());
assertEquals("addRequest", 2147483647, coalescedRequest.getNbRequested());
- assertEquals("addRequest", 200, coalescedRequest.getBlockSize());
-
}
// ------------------------------------------------------------------------
private static final String DIRECTORY = "testfiles";
private static final String TEST_STREAM = "A-Test-10K";
private static final int NB_EVENTS = 5000;
- private static final int BLOCK_SIZE = 100;
// Initialize the test trace
private TmfTraceStub fTrace = null;
try {
URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TmfTraceStub(test.getPath(), 500);
+ fTrace = new TmfTraceStub(test.getPath(), 500, false, null, null);
} catch (TmfTraceException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
final long REQUEST_OFFSET = 1000;
requestedEvents1 = new Vector<ITmfEvent>();
- request1 = new TmfEventRequest(ITmfEvent.class, range, signal.fIndex, NB_EVENTS, BLOCK_SIZE) {
- int nbRead = 0;
+ request1 = new TmfEventRequest(ITmfEvent.class, range, signal.fIndex,
+ NB_EVENTS, ExecutionType.FOREGROUND) {
@Override
public void handleData(ITmfEvent event) {
super.handleData(event);
if (!isCompleted()) {
requestedEvents1.add(event);
- if (++nbRead >= BLOCK_SIZE && signal.forceCancel) {
+ if (signal.forceCancel) {
cancel();
}
}
};
requestedEvents2 = new Vector<ITmfEvent>();
- request2 = new TmfEventRequest(ITmfEvent.class, range, signal.fIndex + REQUEST_OFFSET, NB_EVENTS, BLOCK_SIZE) {
+ request2 = new TmfEventRequest(ITmfEvent.class, range,
+ signal.fIndex + REQUEST_OFFSET, NB_EVENTS, ExecutionType.FOREGROUND) {
@Override
public void handleData(ITmfEvent event) {
super.handleData(event);
};
requestedEvents3 = new Vector<ITmfEvent>();
- request3 = new TmfEventRequest(ITmfEvent.class, range, signal.fIndex + 2 * REQUEST_OFFSET, NB_EVENTS, BLOCK_SIZE) {
+ request3 = new TmfEventRequest(ITmfEvent.class, range,
+ signal.fIndex + 2 * REQUEST_OFFSET, NB_EVENTS, ExecutionType.FOREGROUND) {
@Override
public void handleData(ITmfEvent event) {
super.handleData(event);
request2.waitForCompletion();
request3.waitForCompletion();
- assertEquals("Request1: nbEvents", BLOCK_SIZE, requestedEvents1.size());
assertTrue("Request1: isCompleted", request1.isCompleted());
assertTrue("Request1: isCancelled", request1.isCancelled());
// Ensure that we have distinct events.
// Don't go overboard: we are not validating the stub!
- for (int i = 0; i < BLOCK_SIZE; i++) {
- assertEquals("Distinct events", i + 1 + request1.getIndex(), requestedEvents1.get(i).getTimestamp().getValue());
- }
for (int i = 0; i < NB_EVENTS; i++) {
assertEquals("Distinct events", i + 1 + request2.getIndex(), requestedEvents2.get(i).getTimestamp().getValue());
assertEquals("Distinct events", i + 1 + request3.getIndex(), requestedEvents3.get(i).getTimestamp().getValue());
@Before
public void setUp() {
TmfDataRequest.reset();
- fRequest1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100, 200);
- fRequest2 = new TmfDataRequestStub(ITmfEvent.class, 20, 100, 200);
- fRequest3 = new TmfDataRequestStub(ITmfEvent.class, 20, 200, 200);
- fRequest4 = new TmfDataRequestStub(ITmfEvent.class, 20, 200, 300);
- fRequest1b = new TmfDataRequestStub(ITmfEvent.class, 10, 100, 200);
- fRequest1c = new TmfDataRequestStub(ITmfEvent.class, 10, 100, 200);
+ fRequest1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
+ fRequest2 = new TmfDataRequestStub(ITmfEvent.class, 20, 100);
+ fRequest3 = new TmfDataRequestStub(ITmfEvent.class, 20, 200);
+ fRequest4 = new TmfDataRequestStub(ITmfEvent.class, 20, 200);
+ fRequest1b = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
+ fRequest1c = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
fRequestCount = fRequest1c.getRequestId() + 1;
}
private static TmfDataRequest setupTestRequest(final boolean[] flags) {
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 10, 100, 200) {
+ TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 10, 100) {
@Override
public void handleCompleted() {
super.handleCompleted();
@Test
public void testTmfDataRequestIndexNbEventsBlocksize() {
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 10, 100, 200);
+ TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
assertEquals("getRequestId", fRequestCount++, request.getRequestId());
assertEquals("getDataType", ITmfEvent.class, request.getDataType());
@Test
public void testToString() {
- String expected1 = "[TmfDataRequestStub(0,ITmfEvent,FOREGROUND,10,100,200)]";
- String expected2 = "[TmfDataRequestStub(1,ITmfEvent,FOREGROUND,20,100,200)]";
- String expected3 = "[TmfDataRequestStub(2,ITmfEvent,FOREGROUND,20,200,200)]";
- String expected4 = "[TmfDataRequestStub(3,ITmfEvent,FOREGROUND,20,200,300)]";
+ String expected1 = "[TmfDataRequestStub(0,ITmfEvent,FOREGROUND,10,100)]";
+ String expected2 = "[TmfDataRequestStub(1,ITmfEvent,FOREGROUND,20,100)]";
+ String expected3 = "[TmfDataRequestStub(2,ITmfEvent,FOREGROUND,20,200)]";
+ String expected4 = "[TmfDataRequestStub(3,ITmfEvent,FOREGROUND,20,200)]";
assertEquals("toString", expected1, fRequest1.toString());
assertEquals("toString", expected2, fRequest2.toString());
@Test
public void testToString() {
- String expected1 = "[TmfEventRequestStub(0,ITmfEvent,FOREGROUND," + range1 + ",0,100,200)]";
- String expected2 = "[TmfEventRequestStub(1,ITmfEvent,FOREGROUND," + range2 + ",0,100,200)]";
- String expected3 = "[TmfEventRequestStub(2,ITmfEvent,FOREGROUND," + range2 + ",0,200,200)]";
- String expected4 = "[TmfEventRequestStub(3,ITmfEvent,FOREGROUND," + range2 + ",0,200,300)]";
+ String expected1 = "[TmfEventRequestStub(0,ITmfEvent,FOREGROUND," + range1 + ",0,100)]";
+ String expected2 = "[TmfEventRequestStub(1,ITmfEvent,FOREGROUND," + range2 + ",0,100)]";
+ String expected3 = "[TmfEventRequestStub(2,ITmfEvent,FOREGROUND," + range2 + ",0,200)]";
+ String expected4 = "[TmfEventRequestStub(3,ITmfEvent,FOREGROUND," + range2 + ",0,200)]";
assertEquals("toString", expected1, fRequest1.toString());
assertEquals("toString", expected2, fRequest2.toString());
// ------------------------------------------------------------------------
private class BackgroundRequest extends TmfEventRequest {
- private static final int CHUNK_SIZE = 0;
private int nbEvents = 0;
private String backgroundName;
BackgroundRequest(TmfTimeRange timeRange) {
- super(fixture.getEventType(), timeRange,
+ super(fixture.getEventType(),
+ timeRange,
+ 0,
TmfDataRequest.ALL_DATA,
- CHUNK_SIZE,
ExecutionType.BACKGROUND);
backgroundName = getExecType().toString() + ++fBackgroundId;
}
}
private class ForegroundRequest extends TmfEventRequest {
- private static final int CHUNK_SIZE = 0;
private int nbEvents = 0;
private String foregroundName;
ForegroundRequest(TmfTimeRange timeRange) {
- super(fixture.getEventType(), timeRange,
+ super(fixture.getEventType(),
+ timeRange,
+ 0,
TmfDataRequest.ALL_DATA,
- CHUNK_SIZE,
ExecutionType.FOREGROUND);
foregroundName = getExecType().toString() + ++fForegroundId;
}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.synchronization;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite for org.eclipse.linuxtools.tmf.core.synchronization
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({ TsTransformTest.class,
+ SyncTest.class })
+public class AllTests {
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.synchronization;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventDependency;
+import org.eclipse.linuxtools.tmf.core.synchronization.ITmfTimestampTransform;
+import org.eclipse.linuxtools.tmf.core.synchronization.SyncAlgorithmFullyIncremental;
+import org.eclipse.linuxtools.tmf.core.synchronization.SynchronizationAlgorithm;
+import org.eclipse.linuxtools.tmf.core.synchronization.SynchronizationAlgorithm.SyncQuality;
+import org.eclipse.linuxtools.tmf.core.synchronization.TmfTimestampTransform;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.tests.stubs.event.TmfSyncEventStub;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests for {@link SynchronizationAlgorithm} and its descendants
+ *
+ * @author Geneviève Bastien
+ */
+@SuppressWarnings("nls")
+public class SyncTest {
+
+ private TmfTraceStub t1, t2;
+ private TmfTraceStub[] fTraces;
+
+ /**
+ * Initializing the traces
+ */
+ @Before
+ public void init() {
+ t1 = new TmfTraceStub();
+ t1.init("t1");
+ t2 = new TmfTraceStub();
+ t2.init("t2");
+ TmfTraceStub[] traces = { t1, t2 };
+ fTraces = traces;
+ }
+
+ /**
+ * Testing fully incremental algorithm with communication between the two
+ * traces
+ */
+ @Test
+ public void testFullyIncremental() {
+
+ SynchronizationAlgorithm syncAlgo = new SyncAlgorithmFullyIncremental();
+
+ syncAlgo.init(fTraces);
+
+ assertEquals(SyncQuality.ABSENT, syncAlgo.getSynchronizationQuality(t1, t2));
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(1)),
+ new TmfSyncEventStub(t1, new TmfTimestamp(1))
+ ));
+ assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1 beta 0 ]]", syncAlgo.toString());
+ assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(1)),
+ new TmfSyncEventStub(t2, new TmfTimestamp(3))
+ ));
+ assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1 beta 0 ]]", syncAlgo.toString());
+ assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(2)),
+ new TmfSyncEventStub(t1, new TmfTimestamp(3))
+ ));
+ assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1 beta 0.5 ]]", syncAlgo.toString());
+ assertEquals(SyncQuality.APPROXIMATE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(3)),
+ new TmfSyncEventStub(t2, new TmfTimestamp(5))
+ ));
+ assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 0.75 beta 1.25 ]]", syncAlgo.toString());
+ assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(4)),
+ new TmfSyncEventStub(t2, new TmfTimestamp(8))
+ ));
+ assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 0.75 beta 1.25 ]]", syncAlgo.toString());
+ assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(4)),
+ new TmfSyncEventStub(t1, new TmfTimestamp(5))
+ ));
+ assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1.125 beta 0.875 ]]", syncAlgo.toString());
+ assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(4)),
+ new TmfSyncEventStub(t1, new TmfTimestamp(6))
+ ));
+ assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1.125 beta 0.875 ]]", syncAlgo.toString());
+ assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(6)),
+ new TmfSyncEventStub(t2, new TmfTimestamp(7))
+ ));
+ assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 0.725 beta 1.275 ]]", syncAlgo.toString());
+ assertEquals(SyncQuality.ACCURATE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ ITmfTimestampTransform tt2 = syncAlgo.getTimestampTransform(t2);
+ ITmfTimestampTransform tt1 = syncAlgo.getTimestampTransform(t1);
+
+ assertEquals(syncAlgo.getTimestampTransform("t1"), tt1);
+ assertEquals(TmfTimestampTransform.IDENTITY, tt1);
+ assertEquals(syncAlgo.getTimestampTransform("t2"), tt2);
+
+ /* Make the two hulls intersect */
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(7)),
+ new TmfSyncEventStub(t2, new TmfTimestamp(4))
+ ));
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(7)),
+ new TmfSyncEventStub(t1, new TmfTimestamp(3))
+ ));
+ assertEquals(SyncQuality.FAIL, syncAlgo.getSynchronizationQuality(t1, t2));
+ }
+
+ /**
+ * Testing the fully incremental synchronization algorithm when
+ * communication goes in only one direction
+ */
+ @Test
+ public void testOneHull() {
+
+ SynchronizationAlgorithm syncAlgo = new SyncAlgorithmFullyIncremental();
+
+ syncAlgo.init(fTraces);
+
+ assertEquals(SyncQuality.ABSENT, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(1)),
+ new TmfSyncEventStub(t2, new TmfTimestamp(3)))
+ );
+ assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(2)),
+ new TmfSyncEventStub(t2, new TmfTimestamp(5)))
+ );
+
+ assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(3)),
+ new TmfSyncEventStub(t2, new TmfTimestamp(5)))
+ );
+ assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(4)),
+ new TmfSyncEventStub(t2, new TmfTimestamp(7)))
+ );
+ assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
+ assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1 beta 0 ]]", syncAlgo.toString());
+
+ }
+
+ /**
+ * Testing the fully incremental synchronization algorithm when all
+ * communication from trace1 to trace2 happens before all communication from
+ * trace2 to trace1
+ */
+ @Test
+ public void testDisjoint() {
+
+ SynchronizationAlgorithm syncAlgo = new SyncAlgorithmFullyIncremental();
+
+ syncAlgo.init(fTraces);
+
+ assertEquals(SyncQuality.ABSENT, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(1)),
+ new TmfSyncEventStub(t2, new TmfTimestamp(3)))
+ );
+ assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(2)),
+ new TmfSyncEventStub(t2, new TmfTimestamp(5)))
+ );
+
+ assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(3)),
+ new TmfSyncEventStub(t2, new TmfTimestamp(5)))
+ );
+ assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t1, new TmfTimestamp(4)),
+ new TmfSyncEventStub(t2, new TmfTimestamp(7)))
+ );
+ assertEquals(SyncQuality.INCOMPLETE, syncAlgo.getSynchronizationQuality(t1, t2));
+ assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1 beta 0 ]]", syncAlgo.toString());
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(7)),
+ new TmfSyncEventStub(t1, new TmfTimestamp(6)))
+ );
+ assertEquals(SyncQuality.APPROXIMATE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(8)),
+ new TmfSyncEventStub(t1, new TmfTimestamp(6)))
+ );
+ assertEquals(SyncQuality.APPROXIMATE, syncAlgo.getSynchronizationQuality(t1, t2));
+
+ syncAlgo.addMatch(
+ new TmfEventDependency(new TmfSyncEventStub(t2, new TmfTimestamp(10)),
+ new TmfSyncEventStub(t1, new TmfTimestamp(8)))
+ );
+ assertEquals(SyncQuality.APPROXIMATE, syncAlgo.getSynchronizationQuality(t1, t2));
+ assertEquals("SyncAlgorithmFullyIncremental [Between t1 and t2 [ alpha 1 beta 2.5 ]]", syncAlgo.toString());
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.synchronization;
+
+import static org.junit.Assert.*;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.linuxtools.tmf.core.synchronization.ITmfTimestampTransform;
+import org.eclipse.linuxtools.tmf.core.synchronization.TmfTimestampTransform;
+import org.eclipse.linuxtools.tmf.core.synchronization.TmfTimestampTransformLinear;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.junit.Test;
+
+/**
+ * Tests for {@link TmfTimestampTransform} and its descendants
+ *
+ * @author Geneviève Bastien
+ */
+@SuppressWarnings("nls")
+public class TsTransformTest {
+
+ private long ts = 1361657893526374091L;
+ private ITmfTimestamp oTs = new TmfTimestamp(ts);
+
+ /**
+ * Test the linear transform
+ */
+ @Test
+ public void testLinearTransform() {
+ /* Default constructor */
+ TmfTimestampTransformLinear ttl = new TmfTimestampTransformLinear();
+ assertEquals(1361657893526374091L, ttl.transform(ts));
+ assertEquals(1361657893526374091L, ttl.transform(oTs).getValue());
+
+ /* Just an offset */
+ ttl = new TmfTimestampTransformLinear(BigDecimal.valueOf(1.0), BigDecimal.valueOf(3));
+ assertEquals(1361657893526374094L, ttl.transform(ts));
+ assertEquals(1361657893526374094L, ttl.transform(oTs).getValue());
+
+ /* Just a slope */
+ ttl = new TmfTimestampTransformLinear(BigDecimal.valueOf(2.0), BigDecimal.valueOf(0));
+ assertEquals(2723315787052748182L, ttl.transform(ts));
+ assertEquals(2723315787052748182L, ttl.transform(oTs).getValue());
+
+ /* Offset and slope */
+ ttl = new TmfTimestampTransformLinear(BigDecimal.valueOf(2.0), BigDecimal.valueOf(3));
+ assertEquals(2723315787052748185L, ttl.transform(ts));
+ assertEquals(2723315787052748185L, ttl.transform(oTs).getValue());
+
+ /* Offset and slope */
+ ttl = new TmfTimestampTransformLinear(BigDecimal.valueOf(0.5), BigDecimal.valueOf(0));
+ assertEquals(680828946763187045L, ttl.transform(ts));
+ assertEquals(680828946763187045L, ttl.transform(oTs).getValue());
+ }
+
+ /**
+ * Test for the identity transform
+ */
+ @Test
+ public void testIdentityTransform() {
+ ITmfTimestampTransform tt = TmfTimestampTransform.IDENTITY;
+ assertEquals(ts, tt.transform(ts));
+ assertEquals(oTs, tt.transform(oTs));
+ }
+
+ /**
+ * Test hash and equals function
+ */
+ @Test
+ public void testEquality() {
+ Map<ITmfTimestampTransform, String> map = new HashMap<ITmfTimestampTransform, String>();
+ ITmfTimestampTransform ttl = new TmfTimestampTransformLinear(BigDecimal.valueOf(2.0), BigDecimal.valueOf(3));
+ ITmfTimestampTransform ttl2 = new TmfTimestampTransformLinear(BigDecimal.valueOf(2.0), BigDecimal.valueOf(3));
+ ITmfTimestampTransform ttl3 = new TmfTimestampTransformLinear(BigDecimal.valueOf(3), BigDecimal.valueOf(3));
+ assertEquals(ttl, ttl2);
+ assertFalse(ttl.equals(ttl3));
+ assertFalse(ttl2.equals(ttl3));
+
+ map.put(ttl, "a");
+ assertTrue(map.containsKey(ttl2));
+ assertEquals("a", map.get(ttl));
+
+ ITmfTimestampTransform ti = TmfTimestampTransform.IDENTITY;
+ assertEquals(TmfTimestampTransform.IDENTITY, ti);
+ assertFalse(TmfTimestampTransform.IDENTITY.equals(ttl));
+
+ map.put(ti, "b");
+ assertTrue(map.containsKey(TmfTimestampTransform.IDENTITY));
+ assertEquals("b", map.get(ti));
+
+ assertFalse(ti.equals(ttl));
+ assertFalse(ttl.equals(ti));
+
+ }
+
+ /**
+ * Test the transform composition function
+ */
+ @Test
+ public void testComposition() {
+ long t = 100;
+ ITmfTimestampTransform ti = TmfTimestampTransform.IDENTITY;
+ ITmfTimestampTransform ttl = new TmfTimestampTransformLinear(BigDecimal.valueOf(2.0), BigDecimal.valueOf(3));
+ ITmfTimestampTransform ttl2 = new TmfTimestampTransformLinear(BigDecimal.valueOf(1.5), BigDecimal.valueOf(8));
+
+ ITmfTimestampTransform tc1 = ti.composeWith(ttl);
+ /* Should be ttl */
+ assertEquals(ttl, tc1);
+ assertEquals(203, tc1.transform(t));
+
+ tc1 = ttl.composeWith(ti);
+ /* Should be ttl also */
+ assertEquals(ttl, tc1);
+ assertEquals(203, tc1.transform(t));
+
+ tc1 = ti.composeWith(ti);
+ /* Should be identity */
+ assertEquals(tc1, TmfTimestampTransform.IDENTITY);
+ assertEquals(100, tc1.transform(t));
+
+ tc1 = ttl.composeWith(ttl2);
+ assertEquals(ttl.transform(ttl2.transform(t)), tc1.transform(t));
+ assertEquals(319, tc1.transform(t));
+
+ tc1 = ttl2.composeWith(ttl);
+ assertEquals(ttl2.transform(ttl.transform(t)), tc1.transform(t));
+ assertEquals(312, tc1.transform(t));
+
+ }
+}
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
- TmfCheckpointIndexTest.class,
- TmfCheckpointIndexTest2.class,
- TmfCheckpointTest.class,
TmfContextTest.class,
- TmfExperimentCheckpointIndexTest.class,
TmfExperimentTest.class,
- TmfLocationTest.class,
TmfMultiTraceExperimentTest.class,
TmfTraceManagerTest.class,
TmfTraceTest.class
})
-public class AllTests {
-
-}
\ No newline at end of file
+public class AllTests {}
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Francois Chouinard - Adapted for TMF Trace Model 1.0
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.List;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer;
-import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfEmptyTraceStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfCheckpointIndexTest class.
- */
-@SuppressWarnings("javadoc")
-public class TmfCheckpointIndexTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private static final String DIRECTORY = "testfiles";
- private static final String TEST_STREAM = "A-Test-10K";
- private static final int BLOCK_SIZE = 100;
- private static final int NB_EVENTS = 10000;
- private static TestTrace fTrace = null;
- private static EmptyTestTrace fEmptyTrace = null;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- setupTrace(DIRECTORY + File.separator + TEST_STREAM);
- }
-
- @After
- public void tearDown() {
- fTrace.dispose();
- fTrace = null;
- fEmptyTrace.dispose();
- fEmptyTrace = null;
- }
-
- // ------------------------------------------------------------------------
- // Helper classes
- // ------------------------------------------------------------------------
-
- private static class TestIndexer extends TmfCheckpointIndexer {
- @SuppressWarnings({ })
- public TestIndexer(TestTrace testTrace) {
- super(testTrace, BLOCK_SIZE);
- }
- @SuppressWarnings({ })
- public TestIndexer(EmptyTestTrace testTrace) {
- super(testTrace, BLOCK_SIZE);
- }
- public List<ITmfCheckpoint> getCheckpoints() {
- return getTraceIndex();
- }
- }
-
- private class TestTrace extends TmfTraceStub {
- public TestTrace(String path, int blockSize) throws TmfTraceException {
- super(path, blockSize);
- setIndexer(new TestIndexer(this));
- }
- @Override
- public TestIndexer getIndexer() {
- return (TestIndexer) super.getIndexer();
- }
- }
-
- private class EmptyTestTrace extends TmfEmptyTraceStub {
- public EmptyTestTrace() {
- super();
- setIndexer(new TestIndexer(this));
- }
- @Override
- public TestIndexer getIndexer() {
- return (TestIndexer) super.getIndexer();
- }
- }
-
- // ------------------------------------------------------------------------
- // Helper functions
- // ------------------------------------------------------------------------
-
- private synchronized void setupTrace(final String path) {
- if (fTrace == null) {
- try {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
- final File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TestTrace(test.toURI().getPath(), BLOCK_SIZE);
- fTrace.indexTrace(true);
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- }
-
- if (fEmptyTrace == null) {
- fEmptyTrace = new EmptyTestTrace();
- fEmptyTrace.indexTrace(true);
- }
- }
-
- // ------------------------------------------------------------------------
- // Verify checkpoints
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfTraceIndexing() {
- assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize());
- assertEquals("getTraceSize", NB_EVENTS, fTrace.getNbEvents());
- assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, fTrace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, fTrace.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, fTrace.getEndTime().getValue());
-
- List<ITmfCheckpoint> checkpoints = fTrace.getIndexer().getCheckpoints();
- int pageSize = fTrace.getCacheSize();
- assertTrue("Checkpoints exist", checkpoints != null);
- assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
-
- // Validate that each checkpoint points to the right event
- for (int i = 0; i < checkpoints.size(); i++) {
- ITmfCheckpoint checkpoint = checkpoints.get(i);
- TmfContext context = new TmfContext(checkpoint.getLocation(), i * pageSize);
- ITmfEvent event = fTrace.parseEvent(context);
- assertTrue(context.getRank() == i * pageSize);
- assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
- }
- }
-
- @Test
- public void testEmptyTmfTraceIndexing() {
- assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, fEmptyTrace.getCacheSize());
- assertEquals("getTraceSize", 0, fEmptyTrace.getNbEvents());
- assertEquals("getRange-start", TmfTimestamp.BIG_BANG, fEmptyTrace.getTimeRange().getStartTime());
- assertEquals("getRange-end", TmfTimestamp.BIG_BANG, fEmptyTrace.getTimeRange().getEndTime());
- assertEquals("getStartTime", TmfTimestamp.BIG_BANG, fEmptyTrace.getStartTime());
- assertEquals("getEndTime", TmfTimestamp.BIG_BANG, fEmptyTrace.getEndTime());
-
- List<ITmfCheckpoint> checkpoints = fEmptyTrace.getIndexer().getCheckpoints();
- int pageSize = fEmptyTrace.getCacheSize();
- assertTrue("Checkpoints exist", checkpoints != null);
- assertEquals("Checkpoints size", 0, checkpoints.size());
-
- // Validate that each checkpoint points to the right event
- for (int i = 0; i < checkpoints.size(); i++) {
- ITmfCheckpoint checkpoint = checkpoints.get(i);
- TmfContext context = new TmfContext(checkpoint.getLocation(), i * pageSize);
- ITmfEvent event = fEmptyTrace.parseEvent(context);
- assertTrue(context.getRank() == i * pageSize);
- assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
- }
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Bernd Hufmann - Initial API and implementation
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.List;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfEmptyTraceStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfCheckpointIndexer class (events with same
- * timestamp around checkpoint).
- */
-@SuppressWarnings("javadoc")
-public class TmfCheckpointIndexTest2 {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private static final String DIRECTORY = "testfiles";
- // Trace has 3 events at t=101 at rank 99, 100, 101
- // Trace has events with same timestamp (ts=102) for ranks 102..702 -> 2 checkpoints with same timestamp are created
- private static final String TEST_STREAM = "A-Test-10K-2";
- private static final int BLOCK_SIZE = 100;
- private static final int NB_EVENTS = 702;
- private static TestTrace fTrace = null;
- private static EmptyTestTrace fEmptyTrace = null;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- setupTrace(DIRECTORY + File.separator + TEST_STREAM);
- }
-
- @After
- public void tearDown() {
- fTrace.dispose();
- fTrace = null;
- fEmptyTrace.dispose();
- fEmptyTrace = null;
- }
-
- // ------------------------------------------------------------------------
- // Helper classes
- // ------------------------------------------------------------------------
-
- private static class TestIndexer extends TmfCheckpointIndexer {
- @SuppressWarnings({ })
- public TestIndexer(TestTrace testTrace) {
- super(testTrace, BLOCK_SIZE);
- }
- @SuppressWarnings({ })
- public TestIndexer(EmptyTestTrace testTrace) {
- super(testTrace, BLOCK_SIZE);
- }
- public List<ITmfCheckpoint> getCheckpoints() {
- return getTraceIndex();
- }
- }
-
- private class TestTrace extends TmfTraceStub {
- public TestTrace(String path, int blockSize) throws TmfTraceException {
- super(path, blockSize);
- setIndexer(new TestIndexer(this));
- }
- @Override
- public TestIndexer getIndexer() {
- return (TestIndexer) super.getIndexer();
- }
- }
-
- private class EmptyTestTrace extends TmfEmptyTraceStub {
- public EmptyTestTrace() {
- super();
- setIndexer(new TestIndexer(this));
- }
- @Override
- public TestIndexer getIndexer() {
- return (TestIndexer) super.getIndexer();
- }
- }
-
- // ------------------------------------------------------------------------
- // Helper functions
- // ------------------------------------------------------------------------
-
- private synchronized void setupTrace(final String path) {
- if (fTrace == null) {
- try {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
- final File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TestTrace(test.toURI().getPath(), BLOCK_SIZE);
- fTrace.indexTrace(true);
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- }
-
- if (fEmptyTrace == null) {
- fEmptyTrace = new EmptyTestTrace();
- fEmptyTrace.indexTrace(true);
- }
- }
-
- // ------------------------------------------------------------------------
- // Verify checkpoints
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfTraceMultiTimestamps() {
- assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize());
- assertEquals("getTraceSize", NB_EVENTS, fTrace.getNbEvents());
- assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", 102, fTrace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, fTrace.getStartTime().getValue());
- assertEquals("getEndTime", 102, fTrace.getEndTime().getValue());
-
- List<ITmfCheckpoint> checkpoints = fTrace.getIndexer().getCheckpoints();
- assertTrue("Checkpoints exist", checkpoints != null);
- assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE + 1, checkpoints.size());
-
- // Trace has 3 events with same timestamp (ts=101) at rank 99, 100, 101
-
- // Verify that the event at rank=99 is returned when seeking to ts=101 (first event with this timestamp)
- // and not the event at checkpoint boundary
- TmfTimestamp seekTs = new TmfTimestamp(101, -3, 0);
- ITmfContext ctx = fTrace.seekEvent(seekTs);
- ITmfEvent event = fTrace.getNext(ctx);
-
- assertEquals(99, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- event = fTrace.getNext(ctx);
-
- assertEquals(100, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- event = fTrace.getNext(ctx);
-
- assertEquals(101, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- // Trace has events with same timestamp (ts=102) for ranks 102..702 -> 2 checkpoints with same timestamp are created
- // Verify that the event at rank=102 is returned when seeking to ts=102 (first event with this timestamp)
- // and not the event at checkpoint boundary
- seekTs = new TmfTimestamp(102, -3, 0);
- ctx = fTrace.seekEvent(seekTs);
- event = fTrace.getNext(ctx);
-
- assertEquals(102, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- // Verify seek to first checkpoint
- seekTs = new TmfTimestamp(1, -3, 0);
- ctx = fTrace.seekEvent(seekTs);
- event = fTrace.getNext(ctx);
-
- assertEquals(1, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- // Verify seek to timestamp before first event
- seekTs = new TmfTimestamp(0, -3, 0);
- ctx = fTrace.seekEvent(seekTs);
- event = fTrace.getNext(ctx);
-
- assertEquals(1, ctx.getRank());
- assertEquals(0, new TmfTimestamp(1, -3, 0).compareTo(event.getTimestamp(), false));
-
- // Verify seek to timestamp between first and second checkpoint
- seekTs = new TmfTimestamp(50, -3, 0);
- ctx = fTrace.seekEvent(seekTs);
- event = fTrace.getNext(ctx);
-
- assertEquals(50, ctx.getRank());
- assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
-
- // Verify seek to timestamp after last event in trace
- seekTs = new TmfTimestamp(103, -3, 0);
- ctx = fTrace.seekEvent(seekTs);
- event = fTrace.getNext(ctx);
-
- assertEquals(-1, ctx.getRank());
- assertNull(event);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Francois Chouinard - Adapted for TMF Trace Model 1.0
- * Alexandre Montplaisir - Port to JUnit4
- * Patrick Tasse - Updated for location in checkpoint
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfCheckpoint class.
- */
-@SuppressWarnings("javadoc")
-public class TmfCheckpointTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private ITmfTimestamp fTimestamp1 = new TmfTimestamp();
- private ITmfTimestamp fTimestamp2 = TmfTimestamp.BIG_BANG;
- private ITmfTimestamp fTimestamp3 = TmfTimestamp.BIG_CRUNCH;
-
- private Long aLong1 = 12345L;
- private Long aLong2 = 23456L;
- private Long aLong3 = 34567L;
- private ITmfLocation fLocation1 = new TmfLongLocation(aLong1);
- private ITmfLocation fLocation2 = new TmfLongLocation(aLong2);
- private ITmfLocation fLocation3 = new TmfLongLocation(aLong3);
-
- private TmfCheckpoint fCheckpoint1 = new TmfCheckpoint(fTimestamp1, fLocation1);
- private TmfCheckpoint fCheckpoint2 = new TmfCheckpoint(fTimestamp2, fLocation2);
- private TmfCheckpoint fCheckpoint3 = new TmfCheckpoint(fTimestamp3, fLocation3);
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfCheckpoint() {
- assertEquals("TmfCheckpoint", fTimestamp1, fCheckpoint1.getTimestamp());
- assertEquals("TmfCheckpoint", fLocation1, fCheckpoint1.getLocation());
- }
-
- public void testTmfLocationCopy() {
- final TmfCheckpoint checkpoint = new TmfCheckpoint(fCheckpoint1);
-
- assertEquals("TmfCheckpoint", fTimestamp1, checkpoint.getTimestamp());
- assertEquals("TmfCheckpoint", fLocation1, checkpoint.getLocation());
- }
-
- @Test
- public void testTmfLocationCopy2() {
- try {
- new TmfCheckpoint(null);
- fail("null copy");
- }
- catch (final IllegalArgumentException e) {
- // Success
- }
- catch (final Exception e) {
- fail("wrong exception");
- }
- }
-
- // ------------------------------------------------------------------------
- // compareTo
- // ------------------------------------------------------------------------
-
- @Test
- public void testCompareTo() {
- assertEquals("compareTo", 0, fCheckpoint1.compareTo(fCheckpoint1));
- assertEquals("compareTo", 1, fCheckpoint1.compareTo(fCheckpoint2));
- assertEquals("compareTo", -1, fCheckpoint1.compareTo(fCheckpoint3));
-
- assertEquals("compareTo", -1, fCheckpoint2.compareTo(fCheckpoint1));
- assertEquals("compareTo", 0, fCheckpoint2.compareTo(fCheckpoint2));
- assertEquals("compareTo", -1, fCheckpoint2.compareTo(fCheckpoint3));
-
- assertEquals("compareTo", 1, fCheckpoint3.compareTo(fCheckpoint1));
- assertEquals("compareTo", 1, fCheckpoint3.compareTo(fCheckpoint2));
- assertEquals("compareTo", 0, fCheckpoint3.compareTo(fCheckpoint3));
- }
-
- @Test
- public void testCompareToNull() {
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(null, fLocation1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(null, fLocation2);
- final TmfCheckpoint checkpoint3 = new TmfCheckpoint(null, fLocation3);
- final TmfCheckpoint checkpoint4 = new TmfCheckpoint(null, fLocation1);
-
- // Test the various 'null' vs. '!null' combinations
- assertEquals("compareTo", 0, checkpoint1.compareTo(fCheckpoint1));
- assertEquals("compareTo", 0, fCheckpoint1.compareTo(checkpoint1));
- assertEquals("compareTo", -1, checkpoint1.compareTo(fCheckpoint2));
- assertEquals("compareTo", 1, fCheckpoint2.compareTo(checkpoint1));
- assertEquals("compareTo", -1, checkpoint1.compareTo(fCheckpoint3));
- assertEquals("compareTo", 1, fCheckpoint3.compareTo(checkpoint1));
-
- // Test the 'null' vs. 'null' combinations
- assertEquals("compareTo", 0, checkpoint1.compareTo(checkpoint4));
- assertEquals("compareTo", 0, checkpoint4.compareTo(checkpoint1));
- assertEquals("compareTo", -1, checkpoint1.compareTo(checkpoint2));
- assertEquals("compareTo", 1, checkpoint2.compareTo(checkpoint1));
- assertEquals("compareTo", -1, checkpoint1.compareTo(checkpoint3));
- assertEquals("compareTo", 1, checkpoint3.compareTo(checkpoint1));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fCheckpoint2);
-
- assertTrue("hashCode", fCheckpoint1.hashCode() == checkpoint1.hashCode());
- assertTrue("hashCode", fCheckpoint2.hashCode() == checkpoint2.hashCode());
-
- assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint2.hashCode());
- assertTrue("hashCode", fCheckpoint2.hashCode() != checkpoint1.hashCode());
- }
-
- @Test
- public void testHashCodeNull() {
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(null, fLocation1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fTimestamp1, null);
- final TmfCheckpoint checkpoint3 = new TmfCheckpoint(checkpoint1);
- final TmfCheckpoint checkpoint4 = new TmfCheckpoint(checkpoint2);
-
- assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint1.hashCode());
- assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint2.hashCode());
-
- assertTrue("hashCode", checkpoint1.hashCode() == checkpoint3.hashCode());
- assertTrue("hashCode", checkpoint2.hashCode() == checkpoint4.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fCheckpoint1.equals(fCheckpoint1));
- assertTrue("equals", fCheckpoint2.equals(fCheckpoint2));
-
- assertTrue("equals", !fCheckpoint1.equals(fCheckpoint2));
- assertTrue("equals", !fCheckpoint2.equals(fCheckpoint1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fCheckpoint2);
-
- assertTrue("equals", checkpoint1.equals(fCheckpoint1));
- assertTrue("equals", fCheckpoint1.equals(checkpoint1));
-
- assertTrue("equals", checkpoint2.equals(fCheckpoint2));
- assertTrue("equals", fCheckpoint2.equals(checkpoint2));
- }
-
- @Test
- public void testEqualsTransivity() {
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(checkpoint1);
- final TmfCheckpoint checkpoint3 = new TmfCheckpoint(checkpoint2);
-
- assertTrue("equals", checkpoint1.equals(checkpoint2));
- assertTrue("equals", checkpoint2.equals(checkpoint3));
- assertTrue("equals", checkpoint1.equals(checkpoint3));
- }
-
- @Test
- public void testNotEqual() {
- // Various checkpoints
- final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fTimestamp1, fLocation1);
- final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fTimestamp2, fLocation1);
- final TmfCheckpoint checkpoint3 = new TmfCheckpoint(fTimestamp1, fLocation2);
- final TmfCheckpoint checkpoint4 = new TmfCheckpoint(fTimestamp1, null);
- final TmfCheckpoint checkpoint5 = new TmfCheckpoint(null, fLocation1);
-
- // Null check
- assertFalse("equals", checkpoint1.equals(null));
-
- // Different types
- assertFalse("equals", checkpoint1.equals(new TmfTimestamp()));
-
- // Null locations/location
- assertFalse("equals", checkpoint1.equals(checkpoint4));
- assertFalse("equals", checkpoint1.equals(checkpoint5));
- assertFalse("equals", checkpoint4.equals(checkpoint1));
- assertFalse("equals", checkpoint5.equals(checkpoint1));
-
- // Different locations/location
- assertFalse("equals", checkpoint1.equals(checkpoint2));
- assertFalse("equals", checkpoint1.equals(checkpoint3));
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- final String expected1 = "TmfCheckpoint [fLocation=" + fCheckpoint1.getLocation() +
- ", fTimestamp=" + fCheckpoint1.getTimestamp() + "]";
- final String expected2 = "TmfCheckpoint [fLocation=" + fCheckpoint2.getLocation() +
- ", fTimestamp=" + fCheckpoint2.getTimestamp() + "]";
- final String expected3 = "TmfCheckpoint [fLocation=" + fCheckpoint3.getLocation() +
- ", fTimestamp=" + fCheckpoint3.getTimestamp() + "]";
-
- assertEquals("toString", expected1, fCheckpoint1.toString());
- assertEquals("toString", expected2, fCheckpoint2.toString());
- assertEquals("toString", expected3, fCheckpoint3.toString());
- }
-
-}
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import org.eclipse.linuxtools.tmf.core.tests.trace.location.TmfStringLocation;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
-import org.eclipse.linuxtools.tmf.core.trace.TmfTimestampLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfTimestampLocation;
import org.junit.Test;
/**
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Alexandre Montplaisir - Port to JUnit4
- * Patrick Tasse - Updated for ranks in experiment location
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.List;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfCheckpoint;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfCheckpointIndexTest class.
- */
-@SuppressWarnings("javadoc")
-public class TmfExperimentCheckpointIndexTest {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private static final String DIRECTORY = "testfiles";
- private static final String TEST_STREAM1 = "O-Test-10K";
- private static final String TEST_STREAM2 = "E-Test-10K";
- private static final String EXPERIMENT = "MyExperiment";
- private static int NB_EVENTS = 20000;
- private static int BLOCK_SIZE = 1000;
-
- private static ITmfTrace[] fTestTraces;
- private static TmfExperimentStub fExperiment;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- setupTraces();
- fExperiment = new TmfExperimentStub(EXPERIMENT, fTestTraces, BLOCK_SIZE);
- fExperiment.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
- }
-
- @After
- public void tearDown() {
- fExperiment.dispose();
- fExperiment = null;
- for (ITmfTrace trace : fTestTraces) {
- trace.dispose();
- }
- fTestTraces = null;
- }
-
- private static void setupTraces() {
- final String path1 = DIRECTORY + File.separator + TEST_STREAM1;
- final String path2 = DIRECTORY + File.separator + TEST_STREAM2;
-
- fTestTraces = new ITmfTrace[2];
- try {
- URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path1), null);
- File test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, true);
- fTestTraces[0] = trace1;
- location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path2), null);
- test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, true);
- fTestTraces[1] = trace2;
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
- }
-
- // ------------------------------------------------------------------------
- // Verify checkpoints
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfTraceIndexing() {
- assertEquals("getCacheSize", BLOCK_SIZE, fExperiment.getCacheSize());
- assertEquals("getTraceSize", NB_EVENTS, fExperiment.getNbEvents());
- assertEquals("getRange-start", 1, fExperiment.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, fExperiment.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, fExperiment.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, fExperiment.getEndTime().getValue());
-
- List<ITmfCheckpoint> checkpoints = fExperiment.getIndexer().getCheckpoints();
- int pageSize = fExperiment.getCacheSize();
- assertTrue("Checkpoints exist", checkpoints != null);
- assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
-
- // Validate that each checkpoint points to the right event
- for (int i = 0; i < checkpoints.size(); i++) {
- ITmfCheckpoint checkpoint = checkpoints.get(i);
- ITmfLocation location = checkpoint.getLocation();
- ITmfContext context = fExperiment.seekEvent(location);
- ITmfEvent event = fExperiment.parseEvent(context);
- assertTrue(context.getRank() == i * pageSize);
- assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
- }
- }
-
- // ------------------------------------------------------------------------
- // Streaming
- // ------------------------------------------------------------------------
-
- @Test
- public void testGrowingIndex() {
- ITmfTrace[] testTraces = new TmfTraceStub[2];
- try {
- URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM1), null);
- File test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, false);
- testTraces[0] = trace1;
- location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM2), null);
- test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, false);
- testTraces[1] = trace2;
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- } catch (final IOException e) {
- e.printStackTrace();
- }
-
- TmfExperimentStub experiment = new TmfExperimentStub(EXPERIMENT, testTraces, BLOCK_SIZE);
- int pageSize = experiment.getCacheSize();
-
- // Build the first half of the index
- TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(1, -3), new TmfTimestamp(NB_EVENTS / 2 - 1, -3));
- experiment.getIndexer().buildIndex(0, range, true);
-
- // Validate that each checkpoint points to the right event
- List<ITmfCheckpoint> checkpoints = experiment.getIndexer().getCheckpoints();
- assertTrue("Checkpoints exist", checkpoints != null);
- assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE / 2, checkpoints.size());
-
- // Build the second half of the index
- experiment.getIndexer().buildIndex(NB_EVENTS / 2, TmfTimeRange.ETERNITY, true);
-
- // Validate that each checkpoint points to the right event
- assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
- for (int i = 0; i < checkpoints.size(); i++) {
- ITmfCheckpoint checkpoint = checkpoints.get(i);
- ITmfLocation location = checkpoint.getLocation();
- ITmfContext context = experiment.seekEvent(location);
- ITmfEvent event = experiment.parseEvent(context);
- assertTrue(context.getRank() == i * pageSize);
- assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
- assertEquals("Checkpoint value", i * pageSize + 1, checkpoint.getTimestamp().getValue());
- }
-
- /* Clean up (since we didn't use the class-specific fixtures) */
- experiment.dispose();
- for (ITmfTrace trace : testTraces) {
- trace.dispose();
- }
- }
-
-}
\ No newline at end of file
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
import org.eclipse.linuxtools.tmf.core.statistics.ITmfStatistics;
import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub;
import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
import org.junit.Before;
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
final File test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace = new TmfTraceStub(test.getPath(), 0, true);
+ final TmfTraceStub trace = new TmfTraceStub(test.getPath(), 0, true, null, null);
fTestTraces[0] = trace;
} catch (final TmfTraceException e) {
e.printStackTrace();
@Test
public void testProcessRequestForNbEvents() throws InterruptedException {
- final int blockSize = 100;
final int nbEvents = 1000;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, nbEvents, blockSize) {
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- }
- };
- fExperiment.sendRequest(request);
- request.waitForCompletion();
-
- assertEquals("nbEvents", nbEvents, 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 < nbEvents; i++) {
- assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
- }
- }
-
- @Test
- public void testProcessRequestForNbEvents2() throws InterruptedException {
- final int blockSize = 2 * NB_EVENTS;
- final int nbEvents = 1000;
- final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
-
- final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, nbEvents, blockSize) {
+ final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
+ range, 0, nbEvents, ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
@Test
public void testProcessRequestForAllEvents() throws InterruptedException {
final int nbEvents = TmfDataRequest.ALL_DATA;
- final int blockSize = 1;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final long nbExpectedEvents = NB_EVENTS;
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, nbEvents, blockSize) {
+ final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
+ range, 0, nbEvents, ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
@Test
public void testCancel() throws InterruptedException {
- final int nbEvents = NB_EVENTS;
- final int blockSize = BLOCK_SIZE;
+ final int nbEvents = NB_EVENTS;
+ final int limit = BLOCK_SIZE;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, nbEvents, blockSize) {
+ final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
+ range, 0, nbEvents, ExecutionType.FOREGROUND) {
int nbRead = 0;
+
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
- if (++nbRead == blockSize) {
+ if (++nbRead == limit) {
cancel();
}
}
+
@Override
public void handleCancel() {
- if (requestedEvents.size() < blockSize) {
+ if (requestedEvents.size() < limit) {
System.out.println("aie");
}
}
fExperiment.sendRequest(request);
request.waitForCompletion();
- assertEquals("nbEvents", blockSize, requestedEvents.size());
+ assertEquals("nbEvents", limit, requestedEvents.size());
assertTrue("isCompleted", request.isCompleted());
assertTrue("isCancelled", request.isCancelled());
}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Alexandre Montplaisir - Port to JUnit4
- * Patrick Tasse - Add tests for TmfExperimentLocation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentLocation;
-import org.eclipse.linuxtools.internal.tmf.core.trace.TmfLocationArray;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
-import org.eclipse.linuxtools.tmf.core.trace.TmfTimestampLocation;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfLocation class.
- */
-@SuppressWarnings("javadoc")
-public class TmfLocationTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private String aString = "some location";
- private Long aLong = 12345L;
- private TmfTimestamp aTimestamp = new TmfTimestamp();
- private TmfLocationArray aLocationArray;
-
- private TmfStringLocation fLocation1;
- private TmfStringLocation fLocation2;
- private TmfLongLocation fLocation3;
- private TmfTimestampLocation fLocation4;
- private TmfExperimentLocation fExpLocation;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- fLocation1 = new TmfStringLocation((String) null);
- fLocation2 = new TmfStringLocation(aString);
- fLocation3 = new TmfLongLocation(aLong);
- fLocation4 = new TmfTimestampLocation(aTimestamp);
- aLocationArray = new TmfLocationArray(
- new ITmfLocation[] { fLocation1, fLocation2, fLocation3, fLocation4 },
- new long[] { 1, 2, 3, 4 }
- );
- fExpLocation = new TmfExperimentLocation(aLocationArray);
- }
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfLocation() {
- assertNull("TmfLocation", fLocation1.getLocationInfo());
- assertEquals("TmfLocation", aString, fLocation2.getLocationInfo());
- assertEquals("TmfLocation", aLong, fLocation3.getLocationInfo());
- assertEquals("TmfLocation", aTimestamp, fLocation4.getLocationInfo());
- assertEquals("TmfLocation", aLocationArray, fExpLocation.getLocationInfo());
- }
-
- @Test
- public void testTmfLocationCopy() {
- TmfStringLocation location1 = new TmfStringLocation(fLocation1);
- TmfStringLocation location2 = new TmfStringLocation(fLocation2);
- TmfLongLocation location3 = new TmfLongLocation(fLocation3);
- TmfTimestampLocation location4 = new TmfTimestampLocation(fLocation4);
- TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation);
-
- assertNull("TmfLocation", location1.getLocationInfo());
- assertEquals("TmfLocation", aString, location2.getLocationInfo());
- assertEquals("TmfLocation", aLong, location3.getLocationInfo());
- assertEquals("TmfLocation", aTimestamp, location4.getLocationInfo());
- assertEquals("TmfLocation", aLocationArray, expLocation.getLocationInfo());
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- TmfStringLocation location1 = new TmfStringLocation((String) null);
- TmfStringLocation location2 = new TmfStringLocation(aString);
- TmfLongLocation location3 = new TmfLongLocation(aLong);
- TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation);
- TmfLocationArray locationArray1 = new TmfLocationArray(aLocationArray, 3, fLocation4, 5);
- TmfExperimentLocation expLocation1 = new TmfExperimentLocation(locationArray1);
- TmfLocationArray locationArray2 = new TmfLocationArray(aLocationArray, 3, fLocation3, 4);
- TmfExperimentLocation expLocation2 = new TmfExperimentLocation(locationArray2);
- TmfLocationArray locationArray3 = new TmfLocationArray(
- new ITmfLocation[] { fLocation1, fLocation2, fLocation3 },
- new long[] { 1, 2, 3 }
- );
- TmfExperimentLocation expLocation3 = new TmfExperimentLocation(locationArray3);
-
- assertTrue("hashCode", fLocation1.hashCode() == location1.hashCode());
- assertTrue("hashCode", fLocation2.hashCode() == location2.hashCode());
- assertTrue("hashCode", fLocation3.hashCode() == location3.hashCode());
- assertTrue("hashCode", fExpLocation.hashCode() == expLocation.hashCode());
-
- assertTrue("hashCode", fLocation2.hashCode() != location3.hashCode());
- assertTrue("hashCode", fLocation3.hashCode() != location2.hashCode());
- assertTrue("hashCode", fExpLocation.hashCode() != expLocation1.hashCode());
- assertTrue("hashCode", fExpLocation.hashCode() != expLocation2.hashCode());
- assertTrue("hashCode", fExpLocation.hashCode() != expLocation3.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // toEquals
- // ------------------------------------------------------------------------
-
- private static class TmfLocation2 extends TmfStringLocation {
- public TmfLocation2(String location) {
- super(location);
- }
- }
-
- @Test
- public void testEqualsWrongTypes() {
- ITmfLocation location1 = new TmfStringLocation(aString);
- TmfLocation2 location2 = new TmfLocation2(aString);
-
- assertFalse("equals", location1.equals(location2));
- assertFalse("equals", location2.equals(location1));
- }
-
- @Test
- public void testEqualsWithNulls() {
- TmfStringLocation location1 = new TmfStringLocation(aString);
- TmfStringLocation location2 = new TmfStringLocation((String) null);
-
- assertFalse("equals", location1.equals(location2));
- assertFalse("equals", location2.equals(location1));
- }
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fLocation2.equals(fLocation2));
- assertTrue("equals", fLocation3.equals(fLocation3));
- assertTrue("equals", fExpLocation.equals(fExpLocation));
-
- assertTrue("equals", !fLocation2.equals(fLocation3));
- assertTrue("equals", !fLocation3.equals(fLocation2));
- TmfLocationArray locationArray1 = new TmfLocationArray(aLocationArray, 3, fLocation4, 5);
- TmfExperimentLocation expLocation1 = new TmfExperimentLocation(locationArray1);
- TmfLocationArray locationArray2 = new TmfLocationArray(aLocationArray, 3, fLocation3, 4);
- TmfExperimentLocation expLocation2 = new TmfExperimentLocation(locationArray2);
- TmfLocationArray locationArray3 = new TmfLocationArray(
- new ITmfLocation[] { fLocation1, fLocation2, fLocation3 },
- new long[] { 1, 2, 3 }
- );
- TmfExperimentLocation expLocation3 = new TmfExperimentLocation(locationArray3);
- assertTrue("equals", !fExpLocation.equals(expLocation1));
- assertTrue("equals", !expLocation1.equals(fExpLocation));
- assertTrue("equals", !fExpLocation.equals(expLocation2));
- assertTrue("equals", !expLocation2.equals(fExpLocation));
- assertTrue("equals", !fExpLocation.equals(expLocation3));
- assertTrue("equals", !expLocation3.equals(fExpLocation));
- }
-
- @Test
- public void testEqualsSymmetry() {
- TmfStringLocation location2 = new TmfStringLocation(aString);
- TmfLongLocation location3 = new TmfLongLocation(aLong);
- TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation);
-
- assertTrue("equals", location2.equals(fLocation2));
- assertTrue("equals", fLocation2.equals(location2));
-
- assertTrue("equals", location3.equals(fLocation3));
- assertTrue("equals", fLocation3.equals(location3));
-
- assertTrue("equals", expLocation.equals(fExpLocation));
- assertTrue("equals", fExpLocation.equals(expLocation));
- }
-
- @Test
- public void testEqualsTransivity() {
- TmfStringLocation location1 = new TmfStringLocation(aString);
- TmfStringLocation location2 = new TmfStringLocation(aString);
- TmfStringLocation location3 = new TmfStringLocation(aString);
- TmfExperimentLocation expLocation1 = new TmfExperimentLocation(aLocationArray);
- TmfExperimentLocation expLocation2 = new TmfExperimentLocation(aLocationArray);
- TmfExperimentLocation expLocation3 = new TmfExperimentLocation(aLocationArray);
-
- assertTrue("equals", location1.equals(location2));
- assertTrue("equals", location2.equals(location3));
- assertTrue("equals", location3.equals(location1));
- assertTrue("equals", expLocation1.equals(expLocation2));
- assertTrue("equals", expLocation2.equals(expLocation3));
- assertTrue("equals", expLocation3.equals(expLocation1));
- }
-
- @Test
- public void testEqualsNull() {
- assertTrue("equals", !fLocation2.equals(null));
- assertTrue("equals", !fLocation2.equals(null));
- assertTrue("equals", !fExpLocation.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- String str = "some location";
- Long lng = 12345L;
- TmfTimestamp ts = new TmfTimestamp();
-
- TmfStringLocation location1 = new TmfStringLocation(str);
- TmfLongLocation location2 = new TmfLongLocation(lng);
- TmfTimestampLocation location3 = new TmfTimestampLocation(ts);
- TmfExperimentLocation expLocation = new TmfExperimentLocation(aLocationArray);
-
- String expected1 = "TmfStringLocation [fLocationInfo=" + str + "]";
- String expected2 = "TmfLongLocation [fLocationInfo=" + lng + "]";
- String expected3 = "TmfTimestampLocation [fLocationInfo=" + ts + "]";
- String expected4 = "TmfExperimentLocation [" + aLocationArray + "]";
-
- assertEquals("toString", expected1, location1.toString());
- assertEquals("toString", expected2, location2.toString());
- assertEquals("toString", expected3, location3.toString());
- assertEquals("toString", expected4, expLocation.toString());
- }
-
-}
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub;
import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
import org.junit.AfterClass;
URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path1), null);
File test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, true);
+ final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, true, null, null);
traces[0] = trace1;
location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path2), null);
test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, true);
+ final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, true, null, null);
traces[1] = trace2;
return traces;
@Test
public void testProcessRequestForNbEvents() throws InterruptedException {
- final int blockSize = 100;
final int nbEvents = 1000;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, nbEvents, blockSize) {
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- requestedEvents.add(event);
- }
- };
- fExperiment.sendRequest(request);
- request.waitForCompletion();
-
- assertEquals("nbEvents", nbEvents, 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 < nbEvents; i++) {
- assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
- }
- }
-
- @Test
- public void testProcessRequestForNbEvents2() throws InterruptedException {
- final int blockSize = 2 * NB_EVENTS;
- final int nbEvents = 1000;
- final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
-
- final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, nbEvents, blockSize) {
+ final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
+ range, 0, nbEvents, ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
@Test
public void testProcessRequestForAllEvents() throws InterruptedException {
final int nbEvents = TmfDataRequest.ALL_DATA;
- final int blockSize = 1;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final long nbExpectedEvents = NB_EVENTS;
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, nbEvents, blockSize) {
+ final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
+ range, 0, nbEvents, ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
@Test
public void testCancel() throws InterruptedException {
final int nbEvents = NB_EVENTS;
- final int blockSize = BLOCK_SIZE;
+ final int limit = BLOCK_SIZE;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, nbEvents, blockSize) {
+ final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
+ range, 0, nbEvents, ExecutionType.FOREGROUND) {
int nbRead = 0;
+
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
- if (++nbRead == blockSize) {
+ if (++nbRead == limit) {
cancel();
}
}
- @Override
- public void handleCancel() {
- if (requestedEvents.size() < blockSize) {
- System.out.println("aie");
- }
- }
};
fExperiment.sendRequest(request);
request.waitForCompletion();
- assertEquals("nbEvents", blockSize, requestedEvents.size());
+ assertEquals("nbEvents", limit, requestedEvents.size());
assertTrue("isCompleted", request.isCompleted());
assertTrue("isCancelled", request.isCancelled());
}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.trace;
-
-import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
-
-/**
- * <b><u>TmfStringLocation</u></b>
- * <p>
- * Implement me. Please.
- * <p>
- */
-public class TmfStringLocation extends TmfLocation {
-
- /**
- * @param location the concrete trace location
- */
- public TmfStringLocation(String location) {
- super(location);
- }
-
- /**
- * @param other the other location
- */
- public TmfStringLocation(TmfStringLocation other) {
- super(other.getLocationInfo());
- }
-
- @Override
- public String getLocationInfo() {
- return (String) super.getLocationInfo();
- }
-
-}
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
import org.eclipse.linuxtools.tmf.core.statistics.ITmfStatistics;
import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
import org.junit.After;
import org.junit.Before;
private static final long DEFAULT_INITIAL_OFFSET_VALUE = (1L * 100 * 1000 * 1000); // .1sec
private static final String DIRECTORY = "testfiles";
private static final String TEST_STREAM = "A-Test-10K";
- private static final int BLOCK_SIZE = 500;
private static final int NB_EVENTS = 10000;
private static TmfTraceStub fTrace = null;
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
final File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TmfTraceStub(test.toURI().getPath(), BLOCK_SIZE);
+ fTrace = new TmfTraceStub(test.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null, null);
fTrace.indexTrace(true);
} catch (final TmfTraceException e) {
e.printStackTrace();
// Constructors
// ------------------------------------------------------------------------
- @Test
- public void testStandardConstructor() throws TmfTraceException {
- try {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
- File testfile = new File(FileLocator.toFileURL(location).toURI());
- TmfTraceStub trace = new TmfTraceStub(testfile.toURI().getPath());
- trace.indexTrace(true);
-
- assertEquals("getType", ITmfEvent.class, trace.getType());
- assertNull("getResource", trace.getResource());
- assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
- assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
- assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
- assertEquals("getName", TEST_STREAM, trace.getName());
-
- assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents());
- assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, trace.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
-
- } catch (final URISyntaxException e) {
- fail("URISyntaxException");
- } catch (final IOException e) {
- fail("IOException");
- }
- }
-
- @Test
- public void testStandardConstructorCacheSize() throws TmfTraceException {
- try {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
- File testfile = new File(FileLocator.toFileURL(location).toURI());
- TmfTraceStub trace = new TmfTraceStub(testfile.toURI().getPath(), 0);
- trace.indexTrace(true);
-
- assertEquals("getType", ITmfEvent.class, trace.getType());
- assertNull("getResource", trace.getResource());
- assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
- assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
- assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
- assertEquals("getName", TEST_STREAM, trace.getName());
-
- assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents());
- assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, trace.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
-
- } catch (final URISyntaxException e) {
- fail("URISyntaxException");
- } catch (final IOException e) {
- fail("IOException");
- }
-
- try {
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
- File testfile = new File(FileLocator.toFileURL(location).toURI());
- TmfTraceStub trace = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE);
- trace.indexTrace(true);
-
- assertEquals("getType", ITmfEvent.class, trace.getType());
- assertNull("getResource", trace.getResource());
- assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
- assertEquals("getCacheSize", BLOCK_SIZE, trace.getCacheSize());
- assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
- assertEquals("getName", TEST_STREAM, trace.getName());
-
- assertEquals("getNbEvents", NB_EVENTS, trace.getNbEvents());
- assertEquals("getRange-start", 1, trace.getTimeRange().getStartTime().getValue());
- assertEquals("getRange-end", NB_EVENTS, trace.getTimeRange().getEndTime().getValue());
- assertEquals("getStartTime", 1, trace.getStartTime().getValue());
- assertEquals("getEndTime", NB_EVENTS, trace.getEndTime().getValue());
-
- } catch (final URISyntaxException e) {
- fail("URISyntaxException");
- } catch (final IOException e) {
- fail("IOException");
- }
- }
-
@Test
public void testFullConstructor() throws TmfTraceException {
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
File testfile = new File(FileLocator.toFileURL(location).toURI());
- TmfTraceStub trace = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, null);
+ TmfTraceStub trace = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null, null);
trace.indexTrace(true);
assertEquals("getType", ITmfEvent.class, trace.getType());
assertNull("getResource", trace.getResource());
assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
- assertEquals("getCacheSize", BLOCK_SIZE, trace.getCacheSize());
+ assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
assertEquals("getName", TEST_STREAM, trace.getName());
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
File testfile = new File(FileLocator.toFileURL(location).toURI());
- TmfTraceStub trace = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, interval);
+ TmfTraceStub trace = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, interval);
trace.indexTrace(true);
assertEquals("getType", ITmfEvent.class, trace.getType());
assertNull("getResource", trace.getResource());
assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
- assertEquals("getCacheSize", BLOCK_SIZE, trace.getCacheSize());
+ assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
assertEquals("getStreamingInterval", interval, trace.getStreamingInterval());
assertEquals("getName", TEST_STREAM, trace.getName());
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
File testfile = new File(FileLocator.toFileURL(location).toURI());
- TmfTraceStub original = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, new TmfCheckpointIndexer(null));
+ TmfTraceStub original = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, new TmfCheckpointIndexer(null), null);
TmfTraceStub trace = new TmfTraceStub(original);
trace.indexTrace(true);
assertEquals("getType", ITmfEvent.class, trace.getType());
assertNull("getResource", trace.getResource());
assertEquals("getPath", testfile.toURI().getPath(), trace.getPath());
- assertEquals("getCacheSize", BLOCK_SIZE, trace.getCacheSize());
+ assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, trace.getCacheSize());
assertEquals("getStreamingInterval", 0, trace.getStreamingInterval());
assertEquals("getName", TEST_STREAM, trace.getName());
@Test
public void testProcessEventRequestForAllEvents() throws InterruptedException {
- final int blockSize = 1;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, NB_EVENTS, blockSize) {
+ final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
+ range, 0, NB_EVENTS, ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
@Test
public void testProcessEventRequestForNbEvents() throws InterruptedException {
- final int blockSize = 100;
final int nbEvents = 1000;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, nbEvents, blockSize) {
+ final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
+ range, 0, nbEvents, ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
@Test
public void testProcessEventRequestForSomeEvents() throws InterruptedException {
- final int blockSize = 1;
final long startTime = 100;
final int nbEvents = 1000;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, nbEvents, blockSize) {
+ final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
+ range, 0, nbEvents, ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
@Test
public void testProcessEventRequestForOtherEvents() throws InterruptedException {
- final int blockSize = 1;
final int startIndex = 99;
final long startTime = 100;
final int nbEvents = 1000;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, startIndex, nbEvents, blockSize) {
+ final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
+ range, startIndex, nbEvents, ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
final int nbEvents = 1000;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
- final TmfDataRequest request = new TmfDataRequest(ITmfEvent.class, startIndex, nbEvents) {
+ final TmfDataRequest request = new TmfDataRequest(ITmfEvent.class,
+ startIndex,
+ nbEvents,
+ TmfDataRequest.ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
@Test
public void testCancel() throws InterruptedException {
+ final int limit = 500;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
- final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
+ final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
+ range, 0, NB_EVENTS, ExecutionType.FOREGROUND) {
int nbRead = 0;
+
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
- if (++nbRead == BLOCK_SIZE) {
+ if (++nbRead == limit) {
cancel();
}
}
providers[0].sendRequest(request);
request.waitForCompletion();
- assertEquals("nbEvents", BLOCK_SIZE, requestedEvents.size());
+ assertEquals("nbEvents", limit, requestedEvents.size());
assertTrue("isCompleted", request.isCompleted());
assertTrue("isCancelled", request.isCancelled());
}
assertFalse ("Open trace", fTrace == null);
assertEquals("getType", ITmfEvent.class, fTrace.getType());
assertNull ("getResource", fTrace.getResource());
- assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize());
assertEquals("getStreamingInterval", 0, fTrace.getStreamingInterval());
assertEquals("getName", TEST_STREAM, fTrace.getName());
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
testfile = new File(FileLocator.toFileURL(location).toURI());
- trace = new TmfTraceStub(testfile.toURI().getPath());
+ trace = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null, null);
// verify initial values
TmfTimestamp defaultInitRange = new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
assertEquals("getInitialRangeOffset", defaultInitRange, trace.getInitialRangeOffset());
trace.setInitialRangeOffset(new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE));
trace.indexTrace(true);
+
+ TmfTimestamp initRange = new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE);
+ assertEquals("getInitialRangeOffset", initRange, trace.getInitialRangeOffset());
+
} catch (final URISyntaxException e) {
fail("URISyntaxException");
} catch (final IOException e) {
fail("IOException");
}
- assertFalse ("Open trace", trace == null);
+ }
- TmfTimestamp initRange = new TmfTimestamp(5, ITmfTimestamp.MILLISECOND_SCALE);
- assertEquals("getInitialRangeOffset", initRange, trace.getInitialRangeOffset());
+ /**
+ * Run the String getHostId() method test
+ */
+ @Test
+ public void testTraceHostId() {
+ String a = fTrace.getHostId();
+ assertEquals("A-Test-10K", a);
}
}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexandre Montplaisir - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite for org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TmfCheckpointIndexTest.class,
+ TmfCheckpointIndexTest2.class,
+ TmfCheckpointTest.class,
+ TmfExperimentCheckpointIndexTest.class,
+})
+public class AllTests {}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Adapted for TMF Trace Model 1.0
+ * Alexandre Montplaisir - Port to JUnit4
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfEmptyTraceStub;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test suite for the TmfCheckpointIndexTest class.
+ */
+@SuppressWarnings("javadoc")
+public class TmfCheckpointIndexTest {
+
+ // ------------------------------------------------------------------------
+ // Variables
+ // ------------------------------------------------------------------------
+
+ private static final String DIRECTORY = "testfiles";
+ private static final String TEST_STREAM = "A-Test-10K";
+ private static final int BLOCK_SIZE = 100;
+ private static final int NB_EVENTS = 10000;
+ private static TestTrace fTrace = null;
+ private static EmptyTestTrace fEmptyTrace = null;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ @Before
+ public void setUp() {
+ setupTrace(DIRECTORY + File.separator + TEST_STREAM);
+ }
+
+ @After
+ public void tearDown() {
+ fTrace.dispose();
+ fTrace = null;
+ fEmptyTrace.dispose();
+ fEmptyTrace = null;
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper classes
+ // ------------------------------------------------------------------------
+
+ private static class TestIndexer extends TmfCheckpointIndexer {
+ @SuppressWarnings({ })
+ public TestIndexer(TestTrace testTrace) {
+ super(testTrace, BLOCK_SIZE);
+ }
+ @SuppressWarnings({ })
+ public TestIndexer(EmptyTestTrace testTrace) {
+ super(testTrace, BLOCK_SIZE);
+ }
+ public List<ITmfCheckpoint> getCheckpoints() {
+ return getTraceIndex();
+ }
+ }
+
+ private class TestTrace extends TmfTraceStub {
+ public TestTrace(String path, int blockSize) throws TmfTraceException {
+ super(path, blockSize, false, null, null);
+ setIndexer(new TestIndexer(this));
+ }
+ @Override
+ public TestIndexer getIndexer() {
+ return (TestIndexer) super.getIndexer();
+ }
+ }
+
+ private class EmptyTestTrace extends TmfEmptyTraceStub {
+ public EmptyTestTrace() {
+ super();
+ setIndexer(new TestIndexer(this));
+ }
+ @Override
+ public TestIndexer getIndexer() {
+ return (TestIndexer) super.getIndexer();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper functions
+ // ------------------------------------------------------------------------
+
+ private synchronized void setupTrace(final String path) {
+ if (fTrace == null) {
+ try {
+ final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
+ final File test = new File(FileLocator.toFileURL(location).toURI());
+ fTrace = new TestTrace(test.toURI().getPath(), BLOCK_SIZE);
+ fTrace.indexTrace(true);
+ } catch (final TmfTraceException e) {
+ e.printStackTrace();
+ } catch (final URISyntaxException e) {
+ e.printStackTrace();
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (fEmptyTrace == null) {
+ fEmptyTrace = new EmptyTestTrace();
+ fEmptyTrace.indexTrace(true);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Verify checkpoints
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testTmfTraceIndexing() {
+ assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize());
+ assertEquals("getTraceSize", NB_EVENTS, fTrace.getNbEvents());
+ assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue());
+ assertEquals("getRange-end", NB_EVENTS, fTrace.getTimeRange().getEndTime().getValue());
+ assertEquals("getStartTime", 1, fTrace.getStartTime().getValue());
+ assertEquals("getEndTime", NB_EVENTS, fTrace.getEndTime().getValue());
+
+ List<ITmfCheckpoint> checkpoints = fTrace.getIndexer().getCheckpoints();
+ int pageSize = fTrace.getCacheSize();
+ assertTrue("Checkpoints exist", checkpoints != null);
+ assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
+
+ // Validate that each checkpoint points to the right event
+ for (int i = 0; i < checkpoints.size(); i++) {
+ ITmfCheckpoint checkpoint = checkpoints.get(i);
+ TmfContext context = new TmfContext(checkpoint.getLocation(), i * pageSize);
+ ITmfEvent event = fTrace.parseEvent(context);
+ assertTrue(context.getRank() == i * pageSize);
+ assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
+ }
+ }
+
+ @Test
+ public void testEmptyTmfTraceIndexing() {
+ assertEquals("getCacheSize", ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, fEmptyTrace.getCacheSize());
+ assertEquals("getTraceSize", 0, fEmptyTrace.getNbEvents());
+ assertEquals("getRange-start", TmfTimestamp.BIG_BANG, fEmptyTrace.getTimeRange().getStartTime());
+ assertEquals("getRange-end", TmfTimestamp.BIG_BANG, fEmptyTrace.getTimeRange().getEndTime());
+ assertEquals("getStartTime", TmfTimestamp.BIG_BANG, fEmptyTrace.getStartTime());
+ assertEquals("getEndTime", TmfTimestamp.BIG_BANG, fEmptyTrace.getEndTime());
+
+ List<ITmfCheckpoint> checkpoints = fEmptyTrace.getIndexer().getCheckpoints();
+ int pageSize = fEmptyTrace.getCacheSize();
+ assertTrue("Checkpoints exist", checkpoints != null);
+ assertEquals("Checkpoints size", 0, checkpoints.size());
+
+ // Validate that each checkpoint points to the right event
+ for (int i = 0; i < checkpoints.size(); i++) {
+ ITmfCheckpoint checkpoint = checkpoints.get(i);
+ TmfContext context = new TmfContext(checkpoint.getLocation(), i * pageSize);
+ ITmfEvent event = fEmptyTrace.parseEvent(context);
+ assertTrue(context.getRank() == i * pageSize);
+ assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
+ }
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ * Alexandre Montplaisir - Port to JUnit4
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfEmptyTraceStub;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test suite for the TmfCheckpointIndexer class (events with same
+ * timestamp around checkpoint).
+ */
+@SuppressWarnings("javadoc")
+public class TmfCheckpointIndexTest2 {
+
+ // ------------------------------------------------------------------------
+ // Variables
+ // ------------------------------------------------------------------------
+
+ private static final String DIRECTORY = "testfiles";
+ // Trace has 3 events at t=101 at rank 99, 100, 101
+ // Trace has events with same timestamp (ts=102) for ranks 102..702 -> 2 checkpoints with same timestamp are created
+ private static final String TEST_STREAM = "A-Test-10K-2";
+ private static final int BLOCK_SIZE = 100;
+ private static final int NB_EVENTS = 702;
+ private static TestTrace fTrace = null;
+ private static EmptyTestTrace fEmptyTrace = null;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ @Before
+ public void setUp() {
+ setupTrace(DIRECTORY + File.separator + TEST_STREAM);
+ }
+
+ @After
+ public void tearDown() {
+ fTrace.dispose();
+ fTrace = null;
+ fEmptyTrace.dispose();
+ fEmptyTrace = null;
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper classes
+ // ------------------------------------------------------------------------
+
+ private static class TestIndexer extends TmfCheckpointIndexer {
+ @SuppressWarnings({ })
+ public TestIndexer(TestTrace testTrace) {
+ super(testTrace, BLOCK_SIZE);
+ }
+ @SuppressWarnings({ })
+ public TestIndexer(EmptyTestTrace testTrace) {
+ super(testTrace, BLOCK_SIZE);
+ }
+ public List<ITmfCheckpoint> getCheckpoints() {
+ return getTraceIndex();
+ }
+ }
+
+ private class TestTrace extends TmfTraceStub {
+ public TestTrace(String path, int blockSize) throws TmfTraceException {
+ super(path, blockSize, false, null, null);
+ setIndexer(new TestIndexer(this));
+ }
+ @Override
+ public TestIndexer getIndexer() {
+ return (TestIndexer) super.getIndexer();
+ }
+ }
+
+ private class EmptyTestTrace extends TmfEmptyTraceStub {
+ public EmptyTestTrace() {
+ super();
+ setIndexer(new TestIndexer(this));
+ }
+ @Override
+ public TestIndexer getIndexer() {
+ return (TestIndexer) super.getIndexer();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper functions
+ // ------------------------------------------------------------------------
+
+ private synchronized void setupTrace(final String path) {
+ if (fTrace == null) {
+ try {
+ final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
+ final File test = new File(FileLocator.toFileURL(location).toURI());
+ fTrace = new TestTrace(test.toURI().getPath(), BLOCK_SIZE);
+ fTrace.indexTrace(true);
+ } catch (final TmfTraceException e) {
+ e.printStackTrace();
+ } catch (final URISyntaxException e) {
+ e.printStackTrace();
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (fEmptyTrace == null) {
+ fEmptyTrace = new EmptyTestTrace();
+ fEmptyTrace.indexTrace(true);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Verify checkpoints
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testTmfTraceMultiTimestamps() {
+ assertEquals("getCacheSize", BLOCK_SIZE, fTrace.getCacheSize());
+ assertEquals("getTraceSize", NB_EVENTS, fTrace.getNbEvents());
+ assertEquals("getRange-start", 1, fTrace.getTimeRange().getStartTime().getValue());
+ assertEquals("getRange-end", 102, fTrace.getTimeRange().getEndTime().getValue());
+ assertEquals("getStartTime", 1, fTrace.getStartTime().getValue());
+ assertEquals("getEndTime", 102, fTrace.getEndTime().getValue());
+
+ List<ITmfCheckpoint> checkpoints = fTrace.getIndexer().getCheckpoints();
+ assertTrue("Checkpoints exist", checkpoints != null);
+ assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE + 1, checkpoints.size());
+
+ // Trace has 3 events with same timestamp (ts=101) at rank 99, 100, 101
+
+ // Verify that the event at rank=99 is returned when seeking to ts=101 (first event with this timestamp)
+ // and not the event at checkpoint boundary
+ TmfTimestamp seekTs = new TmfTimestamp(101, -3, 0);
+ ITmfContext ctx = fTrace.seekEvent(seekTs);
+ ITmfEvent event = fTrace.getNext(ctx);
+
+ assertEquals(99, ctx.getRank());
+ assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
+
+ event = fTrace.getNext(ctx);
+
+ assertEquals(100, ctx.getRank());
+ assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
+
+ event = fTrace.getNext(ctx);
+
+ assertEquals(101, ctx.getRank());
+ assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
+
+ // Trace has events with same timestamp (ts=102) for ranks 102..702 -> 2 checkpoints with same timestamp are created
+ // Verify that the event at rank=102 is returned when seeking to ts=102 (first event with this timestamp)
+ // and not the event at checkpoint boundary
+ seekTs = new TmfTimestamp(102, -3, 0);
+ ctx = fTrace.seekEvent(seekTs);
+ event = fTrace.getNext(ctx);
+
+ assertEquals(102, ctx.getRank());
+ assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
+
+ // Verify seek to first checkpoint
+ seekTs = new TmfTimestamp(1, -3, 0);
+ ctx = fTrace.seekEvent(seekTs);
+ event = fTrace.getNext(ctx);
+
+ assertEquals(1, ctx.getRank());
+ assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
+
+ // Verify seek to timestamp before first event
+ seekTs = new TmfTimestamp(0, -3, 0);
+ ctx = fTrace.seekEvent(seekTs);
+ event = fTrace.getNext(ctx);
+
+ assertEquals(1, ctx.getRank());
+ assertEquals(0, new TmfTimestamp(1, -3, 0).compareTo(event.getTimestamp(), false));
+
+ // Verify seek to timestamp between first and second checkpoint
+ seekTs = new TmfTimestamp(50, -3, 0);
+ ctx = fTrace.seekEvent(seekTs);
+ event = fTrace.getNext(ctx);
+
+ assertEquals(50, ctx.getRank());
+ assertEquals(0, seekTs.compareTo(event.getTimestamp(), false));
+
+ // Verify seek to timestamp after last event in trace
+ seekTs = new TmfTimestamp(103, -3, 0);
+ ctx = fTrace.seekEvent(seekTs);
+ event = fTrace.getNext(ctx);
+
+ assertEquals(-1, ctx.getRank());
+ assertNull(event);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Adapted for TMF Trace Model 1.0
+ * Alexandre Montplaisir - Port to JUnit4
+ * Patrick Tasse - Updated for location in checkpoint
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpoint;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
+import org.junit.Test;
+
+/**
+ * Test suite for the TmfCheckpoint class.
+ */
+@SuppressWarnings("javadoc")
+public class TmfCheckpointTest {
+
+ // ------------------------------------------------------------------------
+ // Variables
+ // ------------------------------------------------------------------------
+
+ private ITmfTimestamp fTimestamp1 = new TmfTimestamp();
+ private ITmfTimestamp fTimestamp2 = TmfTimestamp.BIG_BANG;
+ private ITmfTimestamp fTimestamp3 = TmfTimestamp.BIG_CRUNCH;
+
+ private Long aLong1 = 12345L;
+ private Long aLong2 = 23456L;
+ private Long aLong3 = 34567L;
+ private ITmfLocation fLocation1 = new TmfLongLocation(aLong1);
+ private ITmfLocation fLocation2 = new TmfLongLocation(aLong2);
+ private ITmfLocation fLocation3 = new TmfLongLocation(aLong3);
+
+ private TmfCheckpoint fCheckpoint1 = new TmfCheckpoint(fTimestamp1, fLocation1);
+ private TmfCheckpoint fCheckpoint2 = new TmfCheckpoint(fTimestamp2, fLocation2);
+ private TmfCheckpoint fCheckpoint3 = new TmfCheckpoint(fTimestamp3, fLocation3);
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testTmfCheckpoint() {
+ assertEquals("TmfCheckpoint", fTimestamp1, fCheckpoint1.getTimestamp());
+ assertEquals("TmfCheckpoint", fLocation1, fCheckpoint1.getLocation());
+ }
+
+ public void testTmfLocationCopy() {
+ final TmfCheckpoint checkpoint = new TmfCheckpoint(fCheckpoint1);
+
+ assertEquals("TmfCheckpoint", fTimestamp1, checkpoint.getTimestamp());
+ assertEquals("TmfCheckpoint", fLocation1, checkpoint.getLocation());
+ }
+
+ @Test
+ public void testTmfLocationCopy2() {
+ try {
+ new TmfCheckpoint(null);
+ fail("null copy");
+ }
+ catch (final IllegalArgumentException e) {
+ // Success
+ }
+ catch (final Exception e) {
+ fail("wrong exception");
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // compareTo
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testCompareTo() {
+ assertEquals("compareTo", 0, fCheckpoint1.compareTo(fCheckpoint1));
+ assertEquals("compareTo", 1, fCheckpoint1.compareTo(fCheckpoint2));
+ assertEquals("compareTo", -1, fCheckpoint1.compareTo(fCheckpoint3));
+
+ assertEquals("compareTo", -1, fCheckpoint2.compareTo(fCheckpoint1));
+ assertEquals("compareTo", 0, fCheckpoint2.compareTo(fCheckpoint2));
+ assertEquals("compareTo", -1, fCheckpoint2.compareTo(fCheckpoint3));
+
+ assertEquals("compareTo", 1, fCheckpoint3.compareTo(fCheckpoint1));
+ assertEquals("compareTo", 1, fCheckpoint3.compareTo(fCheckpoint2));
+ assertEquals("compareTo", 0, fCheckpoint3.compareTo(fCheckpoint3));
+ }
+
+ @Test
+ public void testCompareToNull() {
+ final TmfCheckpoint checkpoint1 = new TmfCheckpoint(null, fLocation1);
+ final TmfCheckpoint checkpoint2 = new TmfCheckpoint(null, fLocation2);
+ final TmfCheckpoint checkpoint3 = new TmfCheckpoint(null, fLocation3);
+ final TmfCheckpoint checkpoint4 = new TmfCheckpoint(null, fLocation1);
+
+ // Test the various 'null' vs. '!null' combinations
+ assertEquals("compareTo", 0, checkpoint1.compareTo(fCheckpoint1));
+ assertEquals("compareTo", 0, fCheckpoint1.compareTo(checkpoint1));
+ assertEquals("compareTo", -1, checkpoint1.compareTo(fCheckpoint2));
+ assertEquals("compareTo", 1, fCheckpoint2.compareTo(checkpoint1));
+ assertEquals("compareTo", -1, checkpoint1.compareTo(fCheckpoint3));
+ assertEquals("compareTo", 1, fCheckpoint3.compareTo(checkpoint1));
+
+ // Test the 'null' vs. 'null' combinations
+ assertEquals("compareTo", 0, checkpoint1.compareTo(checkpoint4));
+ assertEquals("compareTo", 0, checkpoint4.compareTo(checkpoint1));
+ assertEquals("compareTo", -1, checkpoint1.compareTo(checkpoint2));
+ assertEquals("compareTo", 1, checkpoint2.compareTo(checkpoint1));
+ assertEquals("compareTo", -1, checkpoint1.compareTo(checkpoint3));
+ assertEquals("compareTo", 1, checkpoint3.compareTo(checkpoint1));
+ }
+
+ // ------------------------------------------------------------------------
+ // hashCode
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testHashCode() {
+ final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
+ final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fCheckpoint2);
+
+ assertTrue("hashCode", fCheckpoint1.hashCode() == checkpoint1.hashCode());
+ assertTrue("hashCode", fCheckpoint2.hashCode() == checkpoint2.hashCode());
+
+ assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint2.hashCode());
+ assertTrue("hashCode", fCheckpoint2.hashCode() != checkpoint1.hashCode());
+ }
+
+ @Test
+ public void testHashCodeNull() {
+ final TmfCheckpoint checkpoint1 = new TmfCheckpoint(null, fLocation1);
+ final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fTimestamp1, null);
+ final TmfCheckpoint checkpoint3 = new TmfCheckpoint(checkpoint1);
+ final TmfCheckpoint checkpoint4 = new TmfCheckpoint(checkpoint2);
+
+ assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint1.hashCode());
+ assertTrue("hashCode", fCheckpoint1.hashCode() != checkpoint2.hashCode());
+
+ assertTrue("hashCode", checkpoint1.hashCode() == checkpoint3.hashCode());
+ assertTrue("hashCode", checkpoint2.hashCode() == checkpoint4.hashCode());
+ }
+
+ // ------------------------------------------------------------------------
+ // equals
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testEqualsReflexivity() {
+ assertTrue("equals", fCheckpoint1.equals(fCheckpoint1));
+ assertTrue("equals", fCheckpoint2.equals(fCheckpoint2));
+
+ assertTrue("equals", !fCheckpoint1.equals(fCheckpoint2));
+ assertTrue("equals", !fCheckpoint2.equals(fCheckpoint1));
+ }
+
+ @Test
+ public void testEqualsSymmetry() {
+ final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
+ final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fCheckpoint2);
+
+ assertTrue("equals", checkpoint1.equals(fCheckpoint1));
+ assertTrue("equals", fCheckpoint1.equals(checkpoint1));
+
+ assertTrue("equals", checkpoint2.equals(fCheckpoint2));
+ assertTrue("equals", fCheckpoint2.equals(checkpoint2));
+ }
+
+ @Test
+ public void testEqualsTransivity() {
+ final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fCheckpoint1);
+ final TmfCheckpoint checkpoint2 = new TmfCheckpoint(checkpoint1);
+ final TmfCheckpoint checkpoint3 = new TmfCheckpoint(checkpoint2);
+
+ assertTrue("equals", checkpoint1.equals(checkpoint2));
+ assertTrue("equals", checkpoint2.equals(checkpoint3));
+ assertTrue("equals", checkpoint1.equals(checkpoint3));
+ }
+
+ @Test
+ public void testNotEqual() {
+ // Various checkpoints
+ final TmfCheckpoint checkpoint1 = new TmfCheckpoint(fTimestamp1, fLocation1);
+ final TmfCheckpoint checkpoint2 = new TmfCheckpoint(fTimestamp2, fLocation1);
+ final TmfCheckpoint checkpoint3 = new TmfCheckpoint(fTimestamp1, fLocation2);
+ final TmfCheckpoint checkpoint4 = new TmfCheckpoint(fTimestamp1, null);
+ final TmfCheckpoint checkpoint5 = new TmfCheckpoint(null, fLocation1);
+
+ // Null check
+ assertFalse("equals", checkpoint1.equals(null));
+
+ // Different types
+ assertFalse("equals", checkpoint1.equals(new TmfTimestamp()));
+
+ // Null locations/location
+ assertFalse("equals", checkpoint1.equals(checkpoint4));
+ assertFalse("equals", checkpoint1.equals(checkpoint5));
+ assertFalse("equals", checkpoint4.equals(checkpoint1));
+ assertFalse("equals", checkpoint5.equals(checkpoint1));
+
+ // Different locations/location
+ assertFalse("equals", checkpoint1.equals(checkpoint2));
+ assertFalse("equals", checkpoint1.equals(checkpoint3));
+ }
+
+ // ------------------------------------------------------------------------
+ // toString
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testToString() {
+ final String expected1 = "TmfCheckpoint [fLocation=" + fCheckpoint1.getLocation() +
+ ", fTimestamp=" + fCheckpoint1.getTimestamp() + "]";
+ final String expected2 = "TmfCheckpoint [fLocation=" + fCheckpoint2.getLocation() +
+ ", fTimestamp=" + fCheckpoint2.getTimestamp() + "]";
+ final String expected3 = "TmfCheckpoint [fLocation=" + fCheckpoint3.getLocation() +
+ ", fTimestamp=" + fCheckpoint3.getTimestamp() + "]";
+
+ assertEquals("toString", expected1, fCheckpoint1.toString());
+ assertEquals("toString", expected2, fCheckpoint2.toString());
+ assertEquals("toString", expected3, fCheckpoint3.toString());
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Alexandre Montplaisir - Port to JUnit4
+ * Patrick Tasse - Updated for ranks in experiment location
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.indexer.checkpoint;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test suite for the TmfCheckpointIndexTest class.
+ */
+@SuppressWarnings("javadoc")
+public class TmfExperimentCheckpointIndexTest {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ private static final String DIRECTORY = "testfiles";
+ private static final String TEST_STREAM1 = "O-Test-10K";
+ private static final String TEST_STREAM2 = "E-Test-10K";
+ private static final String EXPERIMENT = "MyExperiment";
+ private static int NB_EVENTS = 20000;
+ private static int BLOCK_SIZE = 1000;
+
+ private static ITmfTrace[] fTestTraces;
+ private static TmfExperimentStub fExperiment;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ @Before
+ public void setUp() {
+ setupTraces();
+ fExperiment = new TmfExperimentStub(EXPERIMENT, fTestTraces, BLOCK_SIZE);
+ fExperiment.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
+ }
+
+ @After
+ public void tearDown() {
+ fExperiment.dispose();
+ fExperiment = null;
+ for (ITmfTrace trace : fTestTraces) {
+ trace.dispose();
+ }
+ fTestTraces = null;
+ }
+
+ private static void setupTraces() {
+ final String path1 = DIRECTORY + File.separator + TEST_STREAM1;
+ final String path2 = DIRECTORY + File.separator + TEST_STREAM2;
+
+ fTestTraces = new ITmfTrace[2];
+ try {
+ URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path1), null);
+ File test = new File(FileLocator.toFileURL(location).toURI());
+ final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, true, null, null);
+ fTestTraces[0] = trace1;
+ location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path2), null);
+ test = new File(FileLocator.toFileURL(location).toURI());
+ final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, true, null, null);
+ fTestTraces[1] = trace2;
+ } catch (final TmfTraceException e) {
+ e.printStackTrace();
+ } catch (final URISyntaxException e) {
+ e.printStackTrace();
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Verify checkpoints
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testTmfTraceIndexing() {
+ assertEquals("getCacheSize", BLOCK_SIZE, fExperiment.getCacheSize());
+ assertEquals("getTraceSize", NB_EVENTS, fExperiment.getNbEvents());
+ assertEquals("getRange-start", 1, fExperiment.getTimeRange().getStartTime().getValue());
+ assertEquals("getRange-end", NB_EVENTS, fExperiment.getTimeRange().getEndTime().getValue());
+ assertEquals("getStartTime", 1, fExperiment.getStartTime().getValue());
+ assertEquals("getEndTime", NB_EVENTS, fExperiment.getEndTime().getValue());
+
+ List<ITmfCheckpoint> checkpoints = fExperiment.getIndexer().getCheckpoints();
+ int pageSize = fExperiment.getCacheSize();
+ assertTrue("Checkpoints exist", checkpoints != null);
+ assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
+
+ // Validate that each checkpoint points to the right event
+ for (int i = 0; i < checkpoints.size(); i++) {
+ ITmfCheckpoint checkpoint = checkpoints.get(i);
+ ITmfLocation location = checkpoint.getLocation();
+ ITmfContext context = fExperiment.seekEvent(location);
+ ITmfEvent event = fExperiment.parseEvent(context);
+ assertTrue(context.getRank() == i * pageSize);
+ assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Streaming
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testGrowingIndex() {
+ ITmfTrace[] testTraces = new TmfTraceStub[2];
+ try {
+ URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM1), null);
+ File test = new File(FileLocator.toFileURL(location).toURI());
+ final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, false, null, null);
+ testTraces[0] = trace1;
+ location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM2), null);
+ test = new File(FileLocator.toFileURL(location).toURI());
+ final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, false, null, null);
+ testTraces[1] = trace2;
+ } catch (final TmfTraceException e) {
+ e.printStackTrace();
+ } catch (final URISyntaxException e) {
+ e.printStackTrace();
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+
+ TmfExperimentStub experiment = new TmfExperimentStub(EXPERIMENT, testTraces, BLOCK_SIZE);
+ int pageSize = experiment.getCacheSize();
+
+ // Build the first half of the index
+ TmfTimeRange range = new TmfTimeRange(new TmfTimestamp(1, -3), new TmfTimestamp(NB_EVENTS / 2 - 1, -3));
+ experiment.getIndexer().buildIndex(0, range, true);
+
+ // Validate that each checkpoint points to the right event
+ List<ITmfCheckpoint> checkpoints = experiment.getIndexer().getCheckpoints();
+ assertTrue("Checkpoints exist", checkpoints != null);
+ assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE / 2, checkpoints.size());
+
+ // Build the second half of the index
+ experiment.getIndexer().buildIndex(NB_EVENTS / 2, TmfTimeRange.ETERNITY, true);
+
+ // Validate that each checkpoint points to the right event
+ assertEquals("Checkpoints size", NB_EVENTS / BLOCK_SIZE, checkpoints.size());
+ for (int i = 0; i < checkpoints.size(); i++) {
+ ITmfCheckpoint checkpoint = checkpoints.get(i);
+ ITmfLocation location = checkpoint.getLocation();
+ ITmfContext context = experiment.seekEvent(location);
+ ITmfEvent event = experiment.parseEvent(context);
+ assertTrue(context.getRank() == i * pageSize);
+ assertTrue((checkpoint.getTimestamp().compareTo(event.getTimestamp(), false) == 0));
+ assertEquals("Checkpoint value", i * pageSize + 1, checkpoint.getTimestamp().getValue());
+ }
+
+ /* Clean up (since we didn't use the class-specific fixtures) */
+ experiment.dispose();
+ for (ITmfTrace trace : testTraces) {
+ trace.dispose();
+ }
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Adjusted for new Trace Model
+ * Alexandre Montplaisir - Port to JUnit4
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.location;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite for org.eclipse.linuxtools.tmf.core.trace.location
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TmfLocationTest.class,
+})
+public class AllTests {}
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Alexandre Montplaisir - Port to JUnit4
+ * Patrick Tasse - Add tests for TmfExperimentLocation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.location;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentLocation;
+import org.eclipse.linuxtools.internal.tmf.core.trace.TmfLocationArray;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfTimestampLocation;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test suite for the TmfLocation class.
+ */
+@SuppressWarnings("javadoc")
+public class TmfLocationTest {
+
+ // ------------------------------------------------------------------------
+ // Variables
+ // ------------------------------------------------------------------------
+
+ private String aString = "some location";
+ private Long aLong = 12345L;
+ private TmfTimestamp aTimestamp = new TmfTimestamp();
+ private TmfLocationArray aLocationArray;
+
+ private TmfStringLocation fLocation1;
+ private TmfStringLocation fLocation2;
+ private TmfLongLocation fLocation3;
+ private TmfTimestampLocation fLocation4;
+ private TmfExperimentLocation fExpLocation;
+
+ // ------------------------------------------------------------------------
+ // Housekeeping
+ // ------------------------------------------------------------------------
+
+ @Before
+ public void setUp() {
+ fLocation1 = new TmfStringLocation((String) null);
+ fLocation2 = new TmfStringLocation(aString);
+ fLocation3 = new TmfLongLocation(aLong);
+ fLocation4 = new TmfTimestampLocation(aTimestamp);
+ aLocationArray = new TmfLocationArray(
+ new ITmfLocation[] { fLocation1, fLocation2, fLocation3, fLocation4 },
+ new long[] { 1, 2, 3, 4 }
+ );
+ fExpLocation = new TmfExperimentLocation(aLocationArray);
+ }
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testTmfLocation() {
+ assertNull("TmfLocation", fLocation1.getLocationInfo());
+ assertEquals("TmfLocation", aString, fLocation2.getLocationInfo());
+ assertEquals("TmfLocation", aLong, fLocation3.getLocationInfo());
+ assertEquals("TmfLocation", aTimestamp, fLocation4.getLocationInfo());
+ assertEquals("TmfLocation", aLocationArray, fExpLocation.getLocationInfo());
+ }
+
+ @Test
+ public void testTmfLocationCopy() {
+ TmfStringLocation location1 = new TmfStringLocation(fLocation1);
+ TmfStringLocation location2 = new TmfStringLocation(fLocation2);
+ TmfLongLocation location3 = new TmfLongLocation(fLocation3);
+ TmfTimestampLocation location4 = new TmfTimestampLocation(fLocation4);
+ TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation);
+
+ assertNull("TmfLocation", location1.getLocationInfo());
+ assertEquals("TmfLocation", aString, location2.getLocationInfo());
+ assertEquals("TmfLocation", aLong, location3.getLocationInfo());
+ assertEquals("TmfLocation", aTimestamp, location4.getLocationInfo());
+ assertEquals("TmfLocation", aLocationArray, expLocation.getLocationInfo());
+ }
+
+ // ------------------------------------------------------------------------
+ // hashCode
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testHashCode() {
+ TmfStringLocation location1 = new TmfStringLocation((String) null);
+ TmfStringLocation location2 = new TmfStringLocation(aString);
+ TmfLongLocation location3 = new TmfLongLocation(aLong);
+ TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation);
+ TmfLocationArray locationArray1 = new TmfLocationArray(aLocationArray, 3, fLocation4, 5);
+ TmfExperimentLocation expLocation1 = new TmfExperimentLocation(locationArray1);
+ TmfLocationArray locationArray2 = new TmfLocationArray(aLocationArray, 3, fLocation3, 4);
+ TmfExperimentLocation expLocation2 = new TmfExperimentLocation(locationArray2);
+ TmfLocationArray locationArray3 = new TmfLocationArray(
+ new ITmfLocation[] { fLocation1, fLocation2, fLocation3 },
+ new long[] { 1, 2, 3 }
+ );
+ TmfExperimentLocation expLocation3 = new TmfExperimentLocation(locationArray3);
+
+ assertTrue("hashCode", fLocation1.hashCode() == location1.hashCode());
+ assertTrue("hashCode", fLocation2.hashCode() == location2.hashCode());
+ assertTrue("hashCode", fLocation3.hashCode() == location3.hashCode());
+ assertTrue("hashCode", fExpLocation.hashCode() == expLocation.hashCode());
+
+ assertTrue("hashCode", fLocation2.hashCode() != location3.hashCode());
+ assertTrue("hashCode", fLocation3.hashCode() != location2.hashCode());
+ assertTrue("hashCode", fExpLocation.hashCode() != expLocation1.hashCode());
+ assertTrue("hashCode", fExpLocation.hashCode() != expLocation2.hashCode());
+ assertTrue("hashCode", fExpLocation.hashCode() != expLocation3.hashCode());
+ }
+
+ // ------------------------------------------------------------------------
+ // toEquals
+ // ------------------------------------------------------------------------
+
+ private static class TmfLocation2 extends TmfStringLocation {
+ public TmfLocation2(String location) {
+ super(location);
+ }
+ }
+
+ @Test
+ public void testEqualsWrongTypes() {
+ ITmfLocation location1 = new TmfStringLocation(aString);
+ TmfLocation2 location2 = new TmfLocation2(aString);
+
+ assertFalse("equals", location1.equals(location2));
+ assertFalse("equals", location2.equals(location1));
+ }
+
+ @Test
+ public void testEqualsWithNulls() {
+ TmfStringLocation location1 = new TmfStringLocation(aString);
+ TmfStringLocation location2 = new TmfStringLocation((String) null);
+
+ assertFalse("equals", location1.equals(location2));
+ assertFalse("equals", location2.equals(location1));
+ }
+
+ @Test
+ public void testEqualsReflexivity() {
+ assertTrue("equals", fLocation2.equals(fLocation2));
+ assertTrue("equals", fLocation3.equals(fLocation3));
+ assertTrue("equals", fExpLocation.equals(fExpLocation));
+
+ assertTrue("equals", !fLocation2.equals(fLocation3));
+ assertTrue("equals", !fLocation3.equals(fLocation2));
+ TmfLocationArray locationArray1 = new TmfLocationArray(aLocationArray, 3, fLocation4, 5);
+ TmfExperimentLocation expLocation1 = new TmfExperimentLocation(locationArray1);
+ TmfLocationArray locationArray2 = new TmfLocationArray(aLocationArray, 3, fLocation3, 4);
+ TmfExperimentLocation expLocation2 = new TmfExperimentLocation(locationArray2);
+ TmfLocationArray locationArray3 = new TmfLocationArray(
+ new ITmfLocation[] { fLocation1, fLocation2, fLocation3 },
+ new long[] { 1, 2, 3 }
+ );
+ TmfExperimentLocation expLocation3 = new TmfExperimentLocation(locationArray3);
+ assertTrue("equals", !fExpLocation.equals(expLocation1));
+ assertTrue("equals", !expLocation1.equals(fExpLocation));
+ assertTrue("equals", !fExpLocation.equals(expLocation2));
+ assertTrue("equals", !expLocation2.equals(fExpLocation));
+ assertTrue("equals", !fExpLocation.equals(expLocation3));
+ assertTrue("equals", !expLocation3.equals(fExpLocation));
+ }
+
+ @Test
+ public void testEqualsSymmetry() {
+ TmfStringLocation location2 = new TmfStringLocation(aString);
+ TmfLongLocation location3 = new TmfLongLocation(aLong);
+ TmfExperimentLocation expLocation = new TmfExperimentLocation(fExpLocation);
+
+ assertTrue("equals", location2.equals(fLocation2));
+ assertTrue("equals", fLocation2.equals(location2));
+
+ assertTrue("equals", location3.equals(fLocation3));
+ assertTrue("equals", fLocation3.equals(location3));
+
+ assertTrue("equals", expLocation.equals(fExpLocation));
+ assertTrue("equals", fExpLocation.equals(expLocation));
+ }
+
+ @Test
+ public void testEqualsTransivity() {
+ TmfStringLocation location1 = new TmfStringLocation(aString);
+ TmfStringLocation location2 = new TmfStringLocation(aString);
+ TmfStringLocation location3 = new TmfStringLocation(aString);
+ TmfExperimentLocation expLocation1 = new TmfExperimentLocation(aLocationArray);
+ TmfExperimentLocation expLocation2 = new TmfExperimentLocation(aLocationArray);
+ TmfExperimentLocation expLocation3 = new TmfExperimentLocation(aLocationArray);
+
+ assertTrue("equals", location1.equals(location2));
+ assertTrue("equals", location2.equals(location3));
+ assertTrue("equals", location3.equals(location1));
+ assertTrue("equals", expLocation1.equals(expLocation2));
+ assertTrue("equals", expLocation2.equals(expLocation3));
+ assertTrue("equals", expLocation3.equals(expLocation1));
+ }
+
+ @Test
+ public void testEqualsNull() {
+ assertTrue("equals", !fLocation2.equals(null));
+ assertTrue("equals", !fLocation2.equals(null));
+ assertTrue("equals", !fExpLocation.equals(null));
+ }
+
+ // ------------------------------------------------------------------------
+ // toString
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testToString() {
+ String str = "some location";
+ Long lng = 12345L;
+ TmfTimestamp ts = new TmfTimestamp();
+
+ TmfStringLocation location1 = new TmfStringLocation(str);
+ TmfLongLocation location2 = new TmfLongLocation(lng);
+ TmfTimestampLocation location3 = new TmfTimestampLocation(ts);
+ TmfExperimentLocation expLocation = new TmfExperimentLocation(aLocationArray);
+
+ String expected1 = "TmfStringLocation [fLocationInfo=" + str + "]";
+ String expected2 = "TmfLongLocation [fLocationInfo=" + lng + "]";
+ String expected3 = "TmfTimestampLocation [fLocationInfo=" + ts + "]";
+ String expected4 = "TmfExperimentLocation [" + aLocationArray + "]";
+
+ assertEquals("toString", expected1, location1.toString());
+ assertEquals("toString", expected2, location2.toString());
+ assertEquals("toString", expected3, location3.toString());
+ assertEquals("toString", expected4, expLocation.toString());
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.tests.trace.location;
+
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLocation;
+
+/**
+ * <b><u>TmfStringLocation</u></b>
+ * <p>
+ * Implement me. Please.
+ * <p>
+ */
+public class TmfStringLocation extends TmfLocation {
+
+ /**
+ * @param location the concrete trace location
+ */
+ public TmfStringLocation(String location) {
+ super(location);
+ }
+
+ /**
+ * @param other the other location
+ */
+ public TmfStringLocation(TmfStringLocation other) {
+ super(other.getLocationInfo());
+ }
+
+ @Override
+ public String getLocationInfo() {
+ return (String) super.getLocationInfo();
+ }
+
+}
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
try {
final File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TmfTraceStub(test.getPath(), 0, true);
+ fTrace = new TmfTraceStub(test.getPath(), 0, true, null, null);
} catch (final TmfTraceException e) {
e.printStackTrace();
} catch (final URISyntaxException e) {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
try {
final File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TmfTraceStub(test.getPath(), 0, true);
+ fTrace = new TmfTraceStub(test.getPath(), 0, true, null, null);
} catch (final TmfTraceException e) {
e.printStackTrace();
} catch (final URISyntaxException e) {
import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
@SuppressWarnings("javadoc")
public class TmfSyntheticEventProviderStub extends TmfEventProvider {
- public static final int BLOCK_SIZE = 100;
public static final int NB_EVENTS = 1000;
public TmfSyntheticEventProviderStub() {
final TmfEventRequest eventRequest = (TmfEventRequest) request;
final TmfTimeRange range = eventRequest.getRange();
final TmfEventRequest subRequest =
- new TmfEventRequest(ITmfEvent.class, range, NB_EVENTS, BLOCK_SIZE) {
+ new TmfEventRequest(ITmfEvent.class, range, 0, NB_EVENTS, ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.tests.stubs.event;
+
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * Event stub used by the synchronization tests
+ *
+ * @author Geneviève Bastien
+ */
+public class TmfSyncEventStub extends TmfEvent {
+
+ private static final String stub = "stub"; //$NON-NLS-1$
+
+ /**
+ * Constructor
+ *
+ * @param trace
+ * The trace of this event
+ * @param timestamp
+ * The timestamp
+ */
+ public TmfSyncEventStub(final ITmfTrace trace, final ITmfTimestamp timestamp) {
+ super(trace,
+ timestamp,
+ stub,
+ new TmfEventTypeStub(),
+ new TmfEventField(stub, stub, null),
+ stub);
+ }
+}
* @param dataType the request data type
*/
public TmfDataRequestStub(final Class<? extends ITmfEvent> dataType) {
- super(dataType);
+ super(dataType, 0, ALL_DATA, ExecutionType.FOREGROUND);
}
/**
* @param index the initial event index
*/
public TmfDataRequestStub(final Class<? extends ITmfEvent> dataType, final int index) {
- super(dataType, index);
+ super(dataType, index, ALL_DATA, ExecutionType.FOREGROUND);
}
/**
* @param index the initial event index
* @param nbRequested the number of events requested
*/
- public TmfDataRequestStub(final Class<? extends ITmfEvent> dataType, final int index, final int nbRequested) {
- super(dataType, index, nbRequested);
- }
-
- /**
- * @param dataType the request data type
- * @param index the initial event index
- * @param nbRequested the number of events requested
- * @param blockSize the event block size
- */
- public TmfDataRequestStub(final Class<? extends ITmfEvent> dataType, final int index, final int nbRequested, final int blockSize) {
- super(dataType, index, nbRequested, blockSize);
+ public TmfDataRequestStub(final Class<? extends ITmfEvent> dataType,
+ final int index, final int nbRequested) {
+ super(dataType, index, nbRequested, ExecutionType.FOREGROUND);
}
@Override
* @param dataType the event type
*/
public TmfEventRequestStub(final Class<? extends ITmfEvent> dataType) {
- super(dataType);
+ super(dataType, TmfTimeRange.ETERNITY, 0, ALL_DATA, ExecutionType.FOREGROUND);
}
/**
* @param range the requested time range
*/
public TmfEventRequestStub(final Class<? extends ITmfEvent> dataType, final TmfTimeRange range) {
- super(dataType, range);
+ super(dataType, range, 0, ALL_DATA, ExecutionType.FOREGROUND);
}
/**
* @param nbRequested the number of events requested
*/
public TmfEventRequestStub(final Class<? extends ITmfEvent> dataType, final TmfTimeRange range, final int nbRequested) {
- super(dataType, range, nbRequested);
+ super(dataType, range, 0, nbRequested, ExecutionType.FOREGROUND);
}
/**
* @param blockSize the event block size
*/
public TmfEventRequestStub(final Class<? extends ITmfEvent> dataType, final TmfTimeRange range, final int nbRequested, final int blockSize) {
- super(dataType, range, nbRequested, blockSize);
+ super(dataType, range, 0, nbRequested, ExecutionType.FOREGROUND);
}
/**
* @param blockSize the event block size
*/
public TmfEventRequestStub(final Class<? extends ITmfEvent> dataType, final TmfTimeRange range, final long index, final int nbRequested, final int blockSize) {
- super(dataType, range, index, nbRequested, blockSize);
+ super(dataType, range, index, nbRequested, ExecutionType.FOREGROUND);
}
@Override
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* <b><u>TmfEmptyTraceStub</u></b>
import java.util.List;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfCheckpoint;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.ITmfCheckpoint;
/**
* <b><u>TmfIndexerStub</u></b>
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
/**
* <b><u>TmfTraceStub</u></b>
* <p>
* Dummy test trace. Use in conjunction with TmfEventParserStub.
*/
-@SuppressWarnings("javadoc")
public class TmfTraceStub extends TmfTrace implements ITmfEventParser {
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ */
public TmfTraceStub() {
super();
setParser(new TmfEventParserStub(this));
}
/**
+ * Constructor with which you can specify a custom streaming interval. The
+ * parser and indexer won't be specified.
+ *
* @param path
- * @throws FileNotFoundException
- */
- public TmfTraceStub(final String path) throws TmfTraceException {
- this(path, ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false);
- }
-
- /**
- * @param path
+ * The path to the trace file
* @param cacheSize
- * @throws FileNotFoundException
+ * The cache size
+ * @param interval
+ * The trace streaming interval
+ * @throws TmfTraceException
+ * If an error occurred opening the trace
*/
- public TmfTraceStub(final String path, final int cacheSize) throws TmfTraceException {
- this(path, cacheSize, false);
- }
-
- /**
- * @param path
- * @param cacheSize
- * @throws FileNotFoundException
- */
- public TmfTraceStub(final String path, final int cacheSize, final long interval) throws TmfTraceException {
+ public TmfTraceStub(final String path,
+ final int cacheSize,
+ final long interval) throws TmfTraceException {
super(null, ITmfEvent.class, path, cacheSize, interval, null, null);
- try {
- fTrace = new RandomAccessFile(path, "r"); //$NON-NLS-1$
- } catch (FileNotFoundException e) {
- throw new TmfTraceException(e.getMessage());
- }
+ setupTrace(path);
setParser(new TmfEventParserStub(this));
}
/**
+ * Constructor to specify the parser and indexer. The streaming interval
+ * will be 0.
+ *
* @param path
+ * The path to the trace file
* @param cacheSize
- * @throws FileNotFoundException
- */
- public TmfTraceStub(final String path, final int cacheSize, final ITmfTraceIndexer indexer) throws TmfTraceException {
- this(path, cacheSize, false, null, indexer);
- }
-
- /**
- * @param path
- * @param waitForCompletion
- * @throws FileNotFoundException
- */
- public TmfTraceStub(final String path, final boolean waitForCompletion) throws TmfTraceException {
- this(path, ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, waitForCompletion);
- }
-
- /**
- * @param path
- * @param cacheSize
+ * The cache size
* @param waitForCompletion
- * @throws FileNotFoundException
+ * Do we block the caller until the trace is indexed, or not.
+ * @param indexer
+ * The trace indexer to use
+ * @param parser
+ * The trace parser. If left 'null', it will use a
+ * {@link TmfEventParserStub}.
+ * @throws TmfTraceException
+ * If an error occurred opening the trace
*/
- public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion) throws TmfTraceException {
- super(null, ITmfEvent.class, path, cacheSize, 0, null, null);
- try {
- fTrace = new RandomAccessFile(path, "r"); //$NON-NLS-1$
- } catch (FileNotFoundException e) {
- throw new TmfTraceException(e.getMessage());
- }
- setParser(new TmfEventParserStub(this));
+ public TmfTraceStub(final String path,
+ final int cacheSize,
+ final boolean waitForCompletion,
+ final ITmfTraceIndexer indexer,
+ final ITmfEventParser parser) throws TmfTraceException {
+ super(null, ITmfEvent.class, path, cacheSize, 0, indexer, null);
+ setupTrace(path);
+ setParser((parser != null) ? parser : new TmfEventParserStub(this));
if (waitForCompletion) {
indexTrace(true);
}
}
/**
- * @param path
- * @param cacheSize
- * @param waitForCompletion
- * @throws FileNotFoundException
+ * Copy constructor
+ *
+ * @param trace
+ * The trace to copy
+ * @throws TmfTraceException
+ * If an error occurred opening the trace
*/
- public TmfTraceStub(final IResource resource, final String path, final int cacheSize, final boolean waitForCompletion) throws TmfTraceException {
- super(resource, ITmfEvent.class, path, cacheSize, 0, null, null);
- try {
- fTrace = new RandomAccessFile(path, "r"); //$NON-NLS-1$
- } catch (FileNotFoundException e) {
- throw new TmfTraceException(e.getMessage());
- }
+ public TmfTraceStub(final TmfTraceStub trace) throws TmfTraceException {
+ super(trace);
+ setupTrace(getPath()); // fPath will be set by the super-constructor
setParser(new TmfEventParserStub(this));
}
- /**
- * @param path
- * @param cacheSize
- * @param waitForCompletion
- * @param parser
- * @throws FileNotFoundException
- */
- public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion,
- final ITmfEventParser parser, final ITmfTraceIndexer indexer) throws TmfTraceException {
- super(null, ITmfEvent.class, path, cacheSize, 0, indexer, null);
+
+ private void setupTrace(String path) throws TmfTraceException {
try {
fTrace = new RandomAccessFile(path, "r"); //$NON-NLS-1$
} catch (FileNotFoundException e) {
throw new TmfTraceException(e.getMessage());
}
- setParser((parser != null) ? parser : new TmfEventParserStub(this));
}
- /**
- * Copy constructor
- */
- public TmfTraceStub(final TmfTraceStub trace) throws TmfTraceException {
- super(trace);
- try {
- fTrace = new RandomAccessFile(getPath(), "r"); //$NON-NLS-1$
- } catch (FileNotFoundException e) {
- throw new TmfTraceException(e.getMessage());
- }
- setParser(new TmfEventParserStub(this));
- }
+ // ------------------------------------------------------------------------
+ // Initializers
+ // ------------------------------------------------------------------------
@Override
public void initTrace(final IResource resource, final String path, final Class<? extends ITmfEvent> type) throws TmfTraceException {
// Accessors
// ------------------------------------------------------------------------
+ /**
+ * @return The file stream to the trace
+ */
public RandomAccessFile getStream() {
return fTrace;
}
+ /**
+ * Set the initial range offset.
+ *
+ * @param initOffset
+ * The new initial range offset
+ */
public void setInitialRangeOffset(ITmfTimestamp initOffset) {
fInitialRangeOffset = initOffset;
}
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.tmf.core;singleton:=true
Bundle-Activator: org.eclipse.linuxtools.internal.tmf.core.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
- org.eclipse.linuxtools.ctf.core;bundle-version="2.1.0"
+ org.eclipse.linuxtools.ctf.core;bundle-version="3.0.0"
Export-Package: org.eclipse.linuxtools.internal.tmf.core;x-friends:="org.eclipse.linuxtools.tmf.core.tests",
org.eclipse.linuxtools.internal.tmf.core.component;x-friends:="org.eclipse.linuxtools.tmf.core.tests",
org.eclipse.linuxtools.internal.tmf.core.request;x-friends:="org.eclipse.linuxtools.tmf.core.tests",
org.eclipse.linuxtools.tmf.core.ctfadaptor,
org.eclipse.linuxtools.tmf.core.event,
org.eclipse.linuxtools.tmf.core.event.lookup,
+ org.eclipse.linuxtools.tmf.core.event.matching,
org.eclipse.linuxtools.tmf.core.exceptions,
org.eclipse.linuxtools.tmf.core.filter,
org.eclipse.linuxtools.tmf.core.filter.model,
org.eclipse.linuxtools.tmf.core.statesystem,
org.eclipse.linuxtools.tmf.core.statevalue,
org.eclipse.linuxtools.tmf.core.statistics,
+ org.eclipse.linuxtools.tmf.core.synchronization,
org.eclipse.linuxtools.tmf.core.timestamp,
org.eclipse.linuxtools.tmf.core.trace,
+ org.eclipse.linuxtools.tmf.core.trace.indexer,
+ org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint,
+ org.eclipse.linuxtools.tmf.core.trace.location,
org.eclipse.linuxtools.tmf.core.uml2sd,
org.eclipse.linuxtools.tmf.core.util
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.tmf.core</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools TMF Core Plug-in</name>
super.stop(context);
}
+
+ // ------------------------------------------------------------------------
+ // Log an IStatus
+ // ------------------------------------------------------------------------
+
+ /**
+ * Log an IStatus object directly
+ *
+ * @param status
+ * The status to log
+ */
+ public static void log(IStatus status) {
+ fPlugin.getLog().log(status);
+ }
+
// ------------------------------------------------------------------------
// Log INFO
// ------------------------------------------------------------------------
public static void logError(String message, Throwable exception) {
fPlugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception));
}
-
}
package org.eclipse.linuxtools.internal.tmf.core.request;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
// Attributes
// ------------------------------------------------------------------------
- /**
- * The list of coalesced requests
- */
- protected Vector<ITmfDataRequest> fRequests = new Vector<ITmfDataRequest>();
+ /**
+ * The list of coalesced requests
+ */
+ protected final List<ITmfDataRequest> fRequests = new ArrayList<ITmfDataRequest>();
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
- /**
- * Request all the events of a given type (high priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- */
- public TmfCoalescedDataRequest(Class<? extends ITmfEvent> dataType) {
- this(dataType, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
- }
-
- /**
- * Request all the events of a given type (given priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param priority the requested execution priority
- */
- public TmfCoalescedDataRequest(Class<? extends ITmfEvent> dataType, ExecutionType priority) {
- this(dataType, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, priority);
- }
-
- /**
- * Request all the events of a given type from the given index (high priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param index the index of the first event to retrieve
- */
- public TmfCoalescedDataRequest(Class<? extends ITmfEvent> dataType, long index) {
- this(dataType, index, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
- }
-
- /**
- * Request all the events of a given type from the given index (given priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param index the index of the first event to retrieve
- * @param priority the requested execution priority
- */
- public TmfCoalescedDataRequest(Class<? extends ITmfEvent> dataType, long index, ExecutionType priority) {
- this(dataType, index, ALL_DATA, DEFAULT_BLOCK_SIZE, priority);
- }
-
- /**
- * Request 'n' events of a given type from the given index (high priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param index the index of the first event to retrieve
- * @param nbRequested the number of events requested
- */
- public TmfCoalescedDataRequest(Class<? extends ITmfEvent> dataType, long index, int nbRequested) {
- this(dataType, index, nbRequested, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
- }
-
- /**
- * Request 'n' events of a given type from the given index (given priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param index the index of the first event to retrieve
- * @param nbRequested the number of events requested
- * @param priority the requested execution priority
- */
- public TmfCoalescedDataRequest(Class<? extends ITmfEvent> dataType, long index, int nbRequested, ExecutionType priority) {
- this(dataType, index, nbRequested, DEFAULT_BLOCK_SIZE, priority);
- }
-
- /**
- * Request 'n' events of a given type from the given index (high priority).
- * Events are returned in blocks of the given size.
- *
- * @param dataType the requested data type
- * @param index the index of the first event to retrieve
- * @param nbRequested the number of events requested
- * @param blockSize the number of events per block
- */
- public TmfCoalescedDataRequest(Class<? extends ITmfEvent> dataType, long index, int nbRequested, int blockSize) {
- super(ITmfEvent.class, index, nbRequested, blockSize, ExecutionType.FOREGROUND);
- }
-
/**
* Request 'n' events of a given type from the given index (given priority).
* Events are returned in blocks of the given size.
*
- * @param dataType the requested data type
- * @param index the index of the first event to retrieve
- * @param nbRequested the number of events requested
- * @param blockSize the number of events per block
- * @param priority the requested execution priority
+ * @param dataType
+ * The requested data type
+ * @param index
+ * The index of the first event to retrieve. Use '0' to start at
+ * the beginning.
+ * @param nbRequested
+ * The number of events requested. You can use
+ * {@link TmfDataRequest#ALL_DATA} to request all events.
+ * @param priority
+ * The requested execution priority
*/
- public TmfCoalescedDataRequest(Class<? extends ITmfEvent> dataType, long index, int nbRequested, int blockSize, ExecutionType priority) {
- super(ITmfEvent.class, index, nbRequested, blockSize, priority);
+ public TmfCoalescedDataRequest(Class<? extends ITmfEvent> dataType,
+ long index,
+ int nbRequested,
+ ExecutionType priority) {
+ super(ITmfEvent.class, index, nbRequested, priority);
}
// ------------------------------------------------------------------------
/**
* Add a request to this one.
*
- * @param request The request to add
+ * @param request
+ * The request to add
*/
public void addRequest(ITmfDataRequest request) {
fRequests.add(request);
fIndex = start;
}
if ((request.getNbRequested() == TmfDataRequest.ALL_DATA) ||
- (fNbRequested == TmfDataRequest.ALL_DATA))
+ (fNbRequested == TmfDataRequest.ALL_DATA))
{
fNbRequested = TmfDataRequest.ALL_DATA;
} else {
}
}
- /**
- * @return The list of IDs of the sub-requests
- */
- @SuppressWarnings("nls")
+ /**
+ * @return The list of IDs of the sub-requests
+ */
+ @SuppressWarnings("nls")
public String getSubRequestIds() {
- StringBuffer result = new StringBuffer("[");
- for (int i = 0; i < fRequests.size(); i++) {
- if (i != 0) {
+ StringBuffer result = new StringBuffer("[");
+ for (int i = 0; i < fRequests.size(); i++) {
+ if (i != 0) {
result.append(", ");
}
- result.append(fRequests.get(i).getRequestId());
- }
- result.append("]");
- return result.toString();
- }
+ result.append(fRequests.get(i).getRequestId());
+ }
+ result.append("]");
+ return result.toString();
+ }
// ------------------------------------------------------------------------
// ITmfDataRequest
// ------------------------------------------------------------------------
@Override
- public void handleData(ITmfEvent data) {
- super.handleData(data);
- // Don't call sub-requests handleData() unless this is a
- // TmfCoalescedDataRequest; extended classes should call
- // the sub-requests handleData().
- if (getClass() == TmfCoalescedDataRequest.class) {
- long index = getIndex() + getNbRead() - 1;
- for (ITmfDataRequest request : fRequests) {
- if (!request.isCompleted()) {
+ public void handleData(ITmfEvent data) {
+ super.handleData(data);
+ // Don't call sub-requests handleData() unless this is a
+ // TmfCoalescedDataRequest; extended classes should call
+ // the sub-requests handleData().
+ if (getClass() == TmfCoalescedDataRequest.class) {
+ long index = getIndex() + getNbRead() - 1;
+ for (ITmfDataRequest request : fRequests) {
+ if (!request.isCompleted()) {
if (request.getDataType().isInstance(data)) {
long start = request.getIndex();
long end = start + request.getNbRequested();
super.start();
}
- @Override
+ @Override
public void done() {
- for (ITmfDataRequest request : fRequests) {
- if (!request.isCompleted()) {
- request.done();
- }
- }
- super.done();
+ for (ITmfDataRequest request : fRequests) {
+ if (!request.isCompleted()) {
+ request.done();
+ }
+ }
+ super.done();
}
@Override
public void fail() {
- for (ITmfDataRequest request : fRequests) {
- request.fail();
- }
- super.fail();
+ for (ITmfDataRequest request : fRequests) {
+ request.fail();
+ }
+ super.fail();
}
@Override
public void cancel() {
- for (ITmfDataRequest request : fRequests) {
- if (!request.isCompleted()) {
- request.cancel();
- }
- }
- super.cancel();
+ for (ITmfDataRequest request : fRequests) {
+ if (!request.isCompleted()) {
+ request.cancel();
+ }
+ }
+ super.cancel();
}
@Override
}
-
// ------------------------------------------------------------------------
// Object
// ------------------------------------------------------------------------
@Override
// All requests have a unique id
public int hashCode() {
- return super.hashCode();
+ return super.hashCode();
}
@Override
public boolean equals(Object other) {
- if (other instanceof TmfCoalescedDataRequest) {
- TmfCoalescedDataRequest request = (TmfCoalescedDataRequest) other;
- return (request.getDataType() == getDataType()) &&
- (request.getIndex() == getIndex()) &&
- (request.getNbRequested() == getNbRequested() &&
- (request.getExecType() == getExecType()));
- }
- return false;
+ if (other instanceof TmfCoalescedDataRequest) {
+ TmfCoalescedDataRequest request = (TmfCoalescedDataRequest) other;
+ return (request.getDataType() == getDataType()) &&
+ (request.getIndex() == getIndex()) &&
+ (request.getNbRequested() == getNbRequested() &&
+ (request.getExecType() == getExecType()));
+ }
+ return false;
}
@Override
@SuppressWarnings("nls")
public String toString() {
return "[TmfCoalescedDataRequest(" + getRequestId() + "," + getDataType().getSimpleName()
- + "," + getExecType() + "," + getIndex() + "," + getNbRequested() + ","
- + getBlockSize() + ", " + fRequests.toString() + ")]";
+ + "," + getExecType() + "," + getIndex() + "," + getNbRequested() + ", "
+ + fRequests.toString() + ")]";
}
}
// Attributes
// ------------------------------------------------------------------------
- private TmfTimeRange fRange; // The requested events time range
+ private TmfTimeRange fRange; // The requested events time range
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
/**
- * Request all the events of a given type (high priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
+ * Request 'n' events of a given type for the given time range (given
+ * priority). Events are returned in blocks of the given size.
*
- * @param dataType the requested data type
+ * @param dataType
+ * The requested data type
+ * @param range
+ * The range of the request. You can use
+ * {@link TmfTimeRange#ETERNITY} to request all events.
+ * @param index
+ * The index of the first event to retrieve. Use '0' to start at
+ * the beginning.
+ * @param nbRequested
+ * The number of events requested. You can use
+ * {@link TmfDataRequest#ALL_DATA} to request all events.
+ * @param priority
+ * The requested execution priority
*/
- public TmfCoalescedEventRequest(Class<? extends ITmfEvent> dataType) {
- this(dataType, TmfTimeRange.ETERNITY, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
- }
-
- /**
- * Request all the events of a given type (given priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param priority the requested execution priority
- */
- public TmfCoalescedEventRequest(Class<? extends ITmfEvent> dataType, ExecutionType priority) {
- this(dataType, TmfTimeRange.ETERNITY, ALL_DATA, DEFAULT_BLOCK_SIZE, priority);
- }
-
- /**
- * Request all the events of a given type for the given time range (high priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param range the time range of the requested events
- */
- public TmfCoalescedEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range) {
- this(dataType, range, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
- }
-
- /**
- * Request all the events of a given type for the given time range (given priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param range the time range of the requested events
- * @param priority the requested execution priority
- */
- public TmfCoalescedEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, ExecutionType priority) {
- this(dataType, range, ALL_DATA, DEFAULT_BLOCK_SIZE, priority);
- }
-
- /**
- * Request 'n' events of a given type from the given time range (high priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param range the time range of the requested events
- * @param nbRequested the number of events requested
- */
- public TmfCoalescedEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, int nbRequested) {
- this(dataType, range, nbRequested, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
- }
-
- /**
- * Request 'n' events of a given type for the given time range (given priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param range the time range of the requested events
- * @param nbRequested the number of events requested
- * @param priority the requested execution priority
- */
- public TmfCoalescedEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, int nbRequested, ExecutionType priority) {
- this(dataType, range, nbRequested, DEFAULT_BLOCK_SIZE, priority);
- }
-
- /**
- * Request 'n' events of a given type for the given time range (high priority).
- * Events are returned in blocks of the given size.
- *
- * @param dataType the requested data type
- * @param range the time range of the requested events
- * @param nbRequested the number of events requested
- * @param blockSize the number of events per block
- */
- public TmfCoalescedEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, int nbRequested, int blockSize) {
- this(dataType, range, 0, nbRequested, blockSize, ExecutionType.FOREGROUND);
- }
-
- /**
- * Request 'n' events of a given type for the given time range (given priority).
- * Events are returned in blocks of the given size.
- *
- * @param dataType the requested data type
- * @param range the time range of the requested events
- * @param nbRequested the number of events requested
- * @param blockSize the number of events per block
- * @param priority the requested execution priority
- */
- public TmfCoalescedEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, int nbRequested, int blockSize, ExecutionType priority) {
- this(dataType, range, 0, nbRequested, blockSize, priority);
- }
-
- /**
- * Request 'n' events of a given type for the given time range (given priority).
- * Events are returned in blocks of the given size.
- *
- * @param dataType the requested data type
- * @param range the time range of the requested events
- * @param index the index of the first event to retrieve
- * @param nbRequested the number of events requested
- * @param blockSize the number of events per block
- * @param priority the requested execution priority
- */
- public TmfCoalescedEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, long index, int nbRequested, int blockSize, ExecutionType priority) {
- super(ITmfEvent.class, index, nbRequested, blockSize, priority);
+ public TmfCoalescedEventRequest(Class<? extends ITmfEvent> dataType,
+ TmfTimeRange range,
+ long index,
+ int nbRequested,
+ ExecutionType priority) {
+ super(ITmfEvent.class, index, nbRequested, priority);
fRange = range;
if (TmfCoreTracer.isRequestTraced()) {
}
}
- @Override
- public boolean isCompatible(ITmfDataRequest request) {
- if (request instanceof ITmfEventRequest) {
- if (super.isCompatible(request)) {
- return overlaps((ITmfEventRequest) request);
- }
- }
- return false;
- }
+ @Override
+ public boolean isCompatible(ITmfDataRequest request) {
+ if (request instanceof ITmfEventRequest) {
+ if (super.isCompatible(request)) {
+ return overlaps((ITmfEventRequest) request);
+ }
+ }
+ return false;
+ }
private boolean overlaps(ITmfEventRequest request) {
ITmfTimestamp startTime = request.getRange().getStartTime();
- ITmfTimestamp endTime = request.getRange().getEndTime();
+ ITmfTimestamp endTime = request.getRange().getEndTime();
return (startTime.compareTo(endTime) <= 0) && (fRange.getStartTime().compareTo(fRange.getEndTime()) <= 0);
}
private void merge(ITmfEventRequest request) {
ITmfTimestamp startTime = request.getRange().getStartTime();
- ITmfTimestamp endTime = request.getRange().getEndTime();
+ ITmfTimestamp endTime = request.getRange().getEndTime();
if (!fRange.contains(startTime) && fRange.getStartTime().compareTo(startTime) > 0) {
fRange = new TmfTimeRange(startTime, fRange.getEndTime());
}
// ITmfEventRequest
// ------------------------------------------------------------------------
- @Override
- public TmfTimeRange getRange() {
- return fRange;
- }
+ @Override
+ public TmfTimeRange getRange() {
+ return fRange;
+ }
- @Override
- public void setStartIndex(int index) {
- setIndex(index);
- }
+ @Override
+ public void setStartIndex(int index) {
+ setIndex(index);
+ }
// ------------------------------------------------------------------------
// Object
@Override
// All requests have a unique id
public int hashCode() {
- return super.hashCode();
+ return super.hashCode();
}
@Override
public boolean equals(Object other) {
- if (other instanceof TmfCoalescedEventRequest) {
- TmfCoalescedEventRequest request = (TmfCoalescedEventRequest) other;
- return (request.getDataType() == getDataType()) &&
- (request.getIndex() == getIndex()) &&
- (request.getNbRequested() == getNbRequested()) &&
- (request.getRange().equals(getRange()));
- }
- if (other instanceof TmfCoalescedDataRequest) {
- return super.equals(other);
- }
- return false;
+ if (other instanceof TmfCoalescedEventRequest) {
+ TmfCoalescedEventRequest request = (TmfCoalescedEventRequest) other;
+ return (request.getDataType() == getDataType()) &&
+ (request.getIndex() == getIndex()) &&
+ (request.getNbRequested() == getNbRequested()) &&
+ (request.getRange().equals(getRange()));
+ }
+ if (other instanceof TmfCoalescedDataRequest) {
+ return super.equals(other);
+ }
+ return false;
}
@Override
public String toString() {
return "[TmfCoalescedEventRequest(" + getRequestId() + "," + getDataType().getSimpleName()
+ "," + getExecType() + "," + getRange() + "," + getIndex() + "," + getNbRequested()
- + "," + getBlockSize() + ", " + fRequests.toString() + ")]";
+ + ", " + fRequests.toString() + ")]";
}
}
}
class StateSystemBuildRequest extends TmfEventRequest {
-
- /** The amount of events queried at a time through the requests */
- private static final int CHUNK_SIZE = 50000;
-
private final HistoryBuilder builder;
private final ITmfStateProvider sci;
private final ITmfTrace trace;
StateSystemBuildRequest(HistoryBuilder builder) {
super(builder.getStateProvider().getExpectedEventType(),
TmfTimeRange.ETERNITY,
+ 0,
TmfDataRequest.ALL_DATA,
- CHUNK_SIZE,
ITmfDataRequest.ExecutionType.BACKGROUND);
this.builder = builder;
this.sci = builder.getStateProvider();
// ------------------------------------------------------------------------
private class CheckpointsRequest extends TmfEventRequest {
-
- /** The amount of events queried at a time through the requests */
- private static final int CHUNK_SIZE = 50000;
-
private final ITmfTrace trace;
private final Map<Long, Long> checkpts;
private long eventCount;
public CheckpointsRequest(ITmfStateProvider input, Map<Long, Long> checkpoints) {
super(input.getExpectedEventType(),
TmfTimeRange.ETERNITY,
+ 0,
TmfDataRequest.ALL_DATA,
- CHUNK_SIZE,
ITmfDataRequest.ExecutionType.BACKGROUND);
checkpoints.clear();
this.trace = input.getTrace();
}
private class PartialStateSystemRequest extends TmfEventRequest {
-
- private static final int CHUNK_SIZE = 50000;
private final ITmfStateProvider sci;
private final ITmfTrace trace;
PartialStateSystemRequest(ITmfStateProvider sci, TmfTimeRange range) {
super(sci.getExpectedEventType(),
range,
+ 0,
TmfDataRequest.ALL_DATA,
- CHUNK_SIZE,
ITmfDataRequest.ExecutionType.BACKGROUND);
this.sci = sci;
this.trace = sci.getTrace();
package org.eclipse.linuxtools.internal.tmf.core.trace;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
import java.util.Arrays;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
protected void newCoalescedDataRequest(ITmfDataRequest request) {
synchronized (fLock) {
TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(request.getDataType(), request.getIndex(),
- request.getNbRequested(), request.getBlockSize(), request.getExecType());
+ request.getNbRequested(), request.getExecType());
coalescedRequest.addRequest(request);
if (TmfCoreTracer.isRequestTraced()) {
TmfCoreTracer.traceRequest(request, "COALESCED with " + coalescedRequest.getRequestId()); //$NON-NLS-1$
if (request.getExecType() == ExecutionType.FOREGROUND) {
queueRequest(request);
} else {
- queueBackgroundRequest(request, request.getBlockSize(), true);
+ queueBackgroundRequest(request, true);
}
}
*
* @param request
* The request
- * @param blockSize
- * The request should be split in chunks of this size
* @param indexing
* Should we index the chunks
+ * @since 3.0
*/
- protected void queueBackgroundRequest(final ITmfDataRequest request, final int blockSize, final boolean indexing) {
+ protected void queueBackgroundRequest(final ITmfDataRequest request, final boolean indexing) {
queueRequest(request);
}
protected synchronized void newCoalescedDataRequest(ITmfDataRequest request) {
if (request instanceof ITmfEventRequest) {
ITmfEventRequest eventRequest = (ITmfEventRequest) request;
- TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(eventRequest.getDataType(), eventRequest.getRange(),
- eventRequest.getIndex(), eventRequest.getNbRequested(), eventRequest.getBlockSize(), eventRequest.getExecType());
+ TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(
+ eventRequest.getDataType(),
+ eventRequest.getRange(),
+ eventRequest.getIndex(),
+ eventRequest.getNbRequested(),
+ eventRequest.getExecType());
coalescedRequest.addRequest(eventRequest);
if (TmfCoreTracer.isRequestTraced()) {
TmfCoreTracer.traceRequest(request, "COALESCED with " + coalescedRequest.getRequestId()); //$NON-NLS-1$
import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader;
import org.eclipse.linuxtools.ctf.core.trace.StreamInputReader;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* The CTF trace reader iterator.
/**
* Method setLocation.
* @param location ITmfLocation<?>
+ * @since 3.0
*/
@Override
public void setLocation(final ITmfLocation location) {
package org.eclipse.linuxtools.tmf.core.ctfadaptor;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLocation;
/**
* The nugget of information that is unique to a location in a CTF trace.
package org.eclipse.linuxtools.tmf.core.ctfadaptor;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* Lightweight Context for CtfTmf traces. Should only use 3 references, 1 ref to
return curRank;
}
+ /**
+ * @since 3.0
+ */
@Override
public ITmfLocation getLocation() {
return curLocation;
return curRank != CtfLocation.INVALID_LOCATION.getTimestamp();
}
+ /**
+ * @since 3.0
+ */
@Override
public void setLocation(ITmfLocation location) {
curLocation = (CtfLocation) location;
sourceCPU = cpu;
typeId = declaration.getId();
eventName = declaration.getName();
+
}
/**
/* Prepare what to pass to CtfTmfEvent's constructor */
final IEventDeclaration eventDecl = eventDef.getDeclaration();
final long ts = eventDef.getTimestamp();
- final CtfTmfTimestamp timestamp = new CtfTmfTimestamp(
+ final CtfTmfTimestamp timestamp = originTrace.createTimestamp(
originTrace.getCTFTrace().timestampCyclesToNanos(ts));
int sourceCPU = eventDef.getCPU();
package org.eclipse.linuxtools.tmf.core.ctfadaptor;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public String toString() {
return getName() + '=' + getFormattedValue();
}
-
- /**
- * Print a numeric value as a string in a given base
- *
- * @param value
- * The value to print as string
- * @param base
- * The base for this value
- * @param signed
- * Is the value signed or not
- * @return formatted number string
- * @since 2.0
- */
- public final static String formatNumber(long value, int base, boolean signed) {
- String s;
-
- /* Format the number correctly according to the integer's base */
- switch (base) {
- case 2:
- s = "0b" + Long.toBinaryString(value); //$NON-NLS-1$
- break;
- case 8:
- s = "0" + Long.toOctalString(value); //$NON-NLS-1$
-
- break;
- case 16:
- s = "0x" + Long.toHexString(value); //$NON-NLS-1$
- break;
- case 10:
- default:
- /* For non-standard base, we'll just print it as a decimal number */
- if (!signed && value < 0) {
- /* Since there are no 'unsigned long', handle this case with BigInteger */
- BigInteger bigInteger = BigInteger.valueOf(value);
- /*
- * powerOfTwo = 2^64 we add 2^64 to the negative number to get
- * the real unsigned value
- */
- BigInteger powerOfTwo = (BigInteger.valueOf(Long.MAX_VALUE)).add(BigInteger.valueOf(1));
- powerOfTwo = powerOfTwo.multiply(BigInteger.valueOf(2));
- bigInteger = bigInteger.add(powerOfTwo);
-
- s = bigInteger.toString();
- } else {
- s = Long.toString(value);
- }
- break;
- }
- return s;
- }
-
}
/**
@Override
public String getFormattedValue() {
- return formatNumber(getValue(), base, signed);
+ return IntegerDefinition.formatNumber(getValue(), base, signed);
}
}
if (formattedValue == null) {
List<String> strings = new ArrayList<String>();
for (Long value : getValue()) {
- strings.add(formatNumber(value, base, signed));
+ strings.add(IntegerDefinition.formatNumber(value, base, signed));
}
formattedValue = strings.toString();
}
/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
+ * Copyright (c) 2012, 2013 Ericsson, École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which
* Contributors:
* Matthew Khouzam - Initial API and implementation
* Patrick Tasse - Updated for removal of context clone
+ * Geneviève Bastien - Added the createTimestamp function
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.ctfadaptor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration;
+import org.eclipse.linuxtools.ctf.core.event.CTFClock;
import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceProperties;
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* The CTf trace handler
*/
protected static final int DEFAULT_CACHE_SIZE = 50000;
+ /*
+ * The Ctf clock unique identifier field
+ */
+ private static final String CLOCK_HOST_PROPERTY = "uuid"; //$NON-NLS-1$
+
// -------------------------------------------
// Fields
// -------------------------------------------
*
* @return null, since the trace has no knowledge of the current location
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#getCurrentLocation()
+ * @since 3.0
*/
@Override
public ITmfLocation getCurrentLocation() {
return null;
}
+ /**
+ * @since 3.0
+ */
@Override
public double getLocationRatio(ITmfLocation location) {
final CtfLocation curLocation = (CtfLocation) location;
* @param location
* ITmfLocation<?>
* @return ITmfContext
+ * @since 3.0
*/
@Override
public synchronized ITmfContext seekEvent(final ITmfLocation location) {
return fTrace;
}
+ /**
+ * Ctf traces have a clock with a unique uuid that will be used to identify
+ * the host. Traces with the same clock uuid will be known to have been made
+ * on the same machine.
+ *
+ * Note: uuid is an optional field, it may not be there for a clock.
+ */
+ @Override
+ public String getHostId() {
+ CTFClock clock = getCTFTrace().getClock();
+ if (clock != null) {
+ String clockHost = (String) clock.getProperty(CLOCK_HOST_PROPERTY);
+ if (clockHost != null) {
+ return clockHost;
+ }
+ }
+ return super.getHostId();
+ }
+
// -------------------------------------------
// ITmfTraceProperties
// -------------------------------------------
public CtfIterator createIterator() {
return new CtfIterator(this);
}
+
+ // ------------------------------------------------------------------------
+ // Timestamp transformation functions
+ // ------------------------------------------------------------------------
+
+ /**
+ * @since 3.0
+ */
+ @Override
+ public CtfTmfTimestamp createTimestamp(long ts) {
+ return new CtfTmfTimestamp(getTimestampTransform().transform(ts));
+ }
}
*/
ITmfEventField getField(int index);
+ /**
+ * Gets the a sub-field of this field, which may be multiple levels down.
+ *
+ * @param path
+ * Array of field names to recursively go through
+ * @return The field at the end, or null if a field in the path cannot be
+ * found
+ * @since 3.0
+ */
+ ITmfEventField getSubField(String[] path);
+
}
return null;
}
+ /**
+ * @since 3.0
+ */
+ @Override
+ public ITmfEventField getSubField(final String[] names) {
+ ITmfEventField field = this;
+ for (String name : names) {
+ field = field.getField(name);
+ if (field == null) {
+ return null;
+ }
+ }
+ return field;
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event.matching;
+
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * This class represent an action to be done when event matches are found. This
+ * interface needs to be implemented by all classes that want to be warned when
+ * new event matches are found. They need to register to an instance of
+ * TmfEventMatches class in order to be informed of matches.
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public interface IMatchProcessingUnit {
+
+ /**
+ * Once the traces are known, hook function to initialize some things
+ *
+ * @param fTraces the set of traces that will be synchronized
+ */
+ void init(ITmfTrace[] fTraces);
+
+ /**
+ * Function called when a match is found
+ *
+ * @param match
+ * The event match
+ */
+ void addMatch(TmfEventDependency match);
+
+ /**
+ * Function called after all matching has been done, to do any post-match
+ * treatment
+ */
+ void matchingEnded();
+
+ /**
+ * Counts the matches
+ *
+ * @return the number of matches
+ */
+ int countMatches();
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event.matching;
+
+
+/**
+ * Interface for matching trace events
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public interface ITmfEventMatching {
+
+ /**
+ * Method that start the process of matching events
+ *
+ * @return Whether the match was completed correctly or not
+ */
+ boolean matchEvents();
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event.matching;
+
+import java.util.List;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventMatching.MatchingType;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * This interface describe a concrete method to match events. Typically it
+ * manages for a given matching type what events/fields are used to match events
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public interface ITmfMatchEventDefinition {
+
+ /**
+ * Returns a list of values for an event that uniquely identifies this event
+ *
+ * @param event
+ * The event for which to compute the key
+ * @return the unique key for this event
+ */
+ List<Object> getUniqueField(ITmfEvent event);
+
+ /**
+ * Verifies whether a trace has all required events to match using this
+ * class
+ *
+ * @param trace
+ * The trace
+ * @return Whether the trace has all required information
+ */
+ boolean canMatchTrace(ITmfTrace trace);
+
+ /**
+ * Return all matching types this definition covers
+ *
+ * @return an array of matching types
+ */
+ MatchingType[] getApplicableMatchingTypes();
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event.matching;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+
+/**
+ * Represents a dependency (match) between two events, where source event leads
+ * to destination event
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public class TmfEventDependency {
+
+ private final ITmfEvent fSourceEvent;
+ private final ITmfEvent fDestEvent;
+
+ /**
+ * Constructor
+ *
+ * @param source
+ * The source event of this dependency
+ * @param destination
+ * The destination event of this dependency
+ */
+ public TmfEventDependency(final ITmfEvent source, final ITmfEvent destination) {
+ fSourceEvent = source;
+ fDestEvent = destination;
+ }
+
+ /**
+ * Getter for fSourceEvent
+ *
+ * @return The source event
+ */
+ public ITmfEvent getSourceEvent() {
+ return fSourceEvent;
+ }
+
+ /**
+ * Getter for fDestEvent
+ *
+ * @return the Destination event
+ */
+ public ITmfEvent getDestinationEvent() {
+ return fDestEvent;
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event.matching;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * Class that does something with a match.
+ *
+ * This default implementation of the class just adds it to a list of matches
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public class TmfEventMatches implements IMatchProcessingUnit {
+
+ /**
+ * The list of matches found
+ */
+ private final List<TmfEventDependency> fMatches;
+
+ /**
+ * Constructor
+ */
+ public TmfEventMatches() {
+ fMatches = new ArrayList<TmfEventDependency>();
+ }
+
+ /**
+ * IMatchProcessingUnit overrides
+ */
+
+ @Override
+ public void init(ITmfTrace[] fTraces) {
+
+ }
+
+ @Override
+ public void addMatch(TmfEventDependency match) {
+ fMatches.add(match);
+ }
+
+ @Override
+ public void matchingEnded() {
+
+ }
+
+ @Override
+ public int countMatches() {
+ return fMatches.size();
+ }
+
+ /**
+ * Returns the match at the specified index
+ *
+ * @param index
+ * The index of the match to get
+ * @return The match at index or null or not present
+ */
+ public TmfEventDependency getMatch(int index) {
+ return fMatches.get(index);
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + " [ Number of matches found: " + fMatches.size() + " ]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event.matching;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.linuxtools.internal.tmf.core.Activator;
+import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * Abstract class to extend to match certain type of events in a trace
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public abstract class TmfEventMatching implements ITmfEventMatching {
+
+ /**
+ * The matching type
+ *
+ * FIXME Not the best place to put this. Have an array of match types as a
+ * parameter of each trace?
+ */
+ public enum MatchingType {
+ /**
+ * NETWORK, match network events
+ */
+ NETWORK
+ }
+
+ /**
+ * The array of traces to match
+ */
+ private final ITmfTrace[] fTraces;
+
+ /**
+ * The class to call once a match is found
+ */
+ private final IMatchProcessingUnit fMatches;
+
+ private static final Map<MatchingType, List<ITmfMatchEventDefinition>> fMatchDefinitions = new HashMap<MatchingType, List<ITmfMatchEventDefinition>>();
+
+ private final Map<ITmfTrace, ITmfMatchEventDefinition> fMatchMap = new HashMap<ITmfTrace, ITmfMatchEventDefinition>();
+
+ /**
+ * Constructor with multiple traces and a match processing object
+ *
+ * @param traces
+ * The set of traces for which to match events
+ * @param tmfEventMatches
+ * The match processing class
+ */
+ public TmfEventMatching(ITmfTrace[] traces, IMatchProcessingUnit tmfEventMatches) {
+ if (tmfEventMatches == null) {
+ throw new IllegalArgumentException();
+ }
+ fTraces = traces;
+ fMatches = tmfEventMatches;
+ }
+
+ /**
+ * Returns the traces to process
+ *
+ * @return The traces
+ */
+ protected ITmfTrace[] getTraces() {
+ return fTraces;
+ }
+
+ /**
+ * Returns the match processing unit
+ *
+ * @return The match processing unit
+ */
+ protected IMatchProcessingUnit getProcessingUnit() {
+ return fMatches;
+ }
+
+ /**
+ * Returns the match event definition corresponding to the trace
+ *
+ * @param trace
+ * The trace
+ * @return The match event definition object
+ */
+ protected ITmfMatchEventDefinition getEventDefinition(ITmfTrace trace) {
+ return fMatchMap.get(trace);
+ }
+
+ /**
+ * Method that initializes any data structure for the event matching. It
+ * also assigns to each trace an event matching definition instance that
+ * applies to the trace
+ */
+ protected void initMatching() {
+ fMatches.init(fTraces);
+ List<ITmfMatchEventDefinition> deflist = fMatchDefinitions.get(getMatchingType());
+ if (deflist == null) {
+ return;
+ }
+ for (ITmfTrace trace : fTraces) {
+ for (ITmfMatchEventDefinition def : deflist) {
+ if (def.canMatchTrace(trace)) {
+ fMatchMap.put(trace, def);
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Calls any post matching methods of the processing class
+ */
+ protected void finalizeMatching() {
+ fMatches.matchingEnded();
+ }
+
+ /**
+ * Prints stats from the matching
+ *
+ * @return string of statistics
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + " [ " + fMatches + " ]";
+ }
+
+ /**
+ * Matches one event
+ *
+ * @param event
+ * The event to match
+ * @param traceno
+ * The number of the trace this event belongs to
+ */
+ protected abstract void matchEvent(ITmfEvent event, int traceno);
+
+ /**
+ * Returns the matching type this class implements
+ *
+ * @return A matching type
+ */
+ protected abstract MatchingType getMatchingType();
+
+ /**
+ * Method that start the process of matching events
+ *
+ * @return Whether the match was completed correctly or not
+ */
+ @Override
+ public boolean matchEvents() {
+
+ /* Are there traces to match? If no, return false */
+ if (!(fTraces.length > 0)) {
+ return false;
+ }
+
+ // TODO Start a new thread here?
+ initMatching();
+
+ /**
+ * For each trace, get the events and for each event, call the
+ * MatchEvent method
+ *
+ * FIXME This would use a lot of memory if the traces are big, because
+ * all involved events from first trace will have to be kept before a
+ * first match is possible with second trace.
+ *
+ * <pre>
+ * Other possible matching strategy:
+ * Incremental:
+ * Sliding window:
+ * Other strategy: start with the shortest trace, take a few events
+ * at the beginning and at the end
+ * Experiment strategy: have the experiment do the request, then events will
+ * come from both traces chronologically, but then instead of ITmfTrace[], it
+ * would be preferable to have experiment
+ * </pre>
+ */
+ for (int i = 0; i < fTraces.length; i++) {
+
+ EventMatchingBuildRequest request = new EventMatchingBuildRequest(this, i);
+
+ /*
+ * Send the request to the trace here, since there is probably no
+ * experiment.
+ */
+ fTraces[i].sendRequest(request);
+ try {
+ request.waitForCompletion();
+ } catch (InterruptedException e) {
+ Activator.logInfo(e.getMessage());
+ }
+ }
+
+ finalizeMatching();
+
+ return true;
+ }
+
+ /**
+ * Registers an event match definition to be used for a certain match type
+ *
+ * @param match
+ * The event matching definition
+ */
+ public static void registerMatchObject(ITmfMatchEventDefinition match) {
+ for (MatchingType type : match.getApplicableMatchingTypes()) {
+ if (!fMatchDefinitions.containsKey(type)) {
+ fMatchDefinitions.put(type, new ArrayList<ITmfMatchEventDefinition>());
+ }
+ fMatchDefinitions.get(type).add(match);
+ }
+ }
+
+}
+
+class EventMatchingBuildRequest extends TmfEventRequest {
+
+ private final TmfEventMatching matching;
+ private final int traceno;
+
+ EventMatchingBuildRequest(TmfEventMatching matching, int traceno) {
+ super(CtfTmfEvent.class,
+ TmfTimeRange.ETERNITY,
+ 0,
+ TmfDataRequest.ALL_DATA,
+ ITmfDataRequest.ExecutionType.FOREGROUND);
+ this.matching = matching;
+ this.traceno = traceno;
+ }
+
+ @Override
+ public void handleData(final ITmfEvent event) {
+ super.handleData(event);
+ if (event != null) {
+ matching.matchEvent(event, traceno);
+ }
+ }
+
+ @Override
+ public void handleSuccess() {
+ super.handleSuccess();
+ }
+
+ @Override
+ public void handleCancel() {
+ super.handleCancel();
+ }
+
+ @Override
+ public void handleFailure() {
+ super.handleFailure();
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event.matching;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.matching.IMatchProcessingUnit;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventDependency;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventMatching;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * This class matches events typically network-style, ie. where some events are
+ * 'send' events and the other 'receive' events or out/in events
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public class TmfNetworkEventMatching extends TmfEventMatching {
+
+ /**
+ * Hashtables for unmatches incoming events
+ */
+ private final List<Map<List<Object>, ITmfEvent>> fUnmatchedIn = new ArrayList<Map<List<Object>, ITmfEvent>>();
+
+ /**
+ * Hashtables for unmatches outgoing events
+ */
+ private final List<Map<List<Object>, ITmfEvent>> fUnmatchedOut = new ArrayList<Map<List<Object>, ITmfEvent>>();
+
+ /**
+ * Enum for in and out types
+ */
+ public enum Direction {
+ /**
+ * The event is a 'receive' type of event
+ */
+ IN,
+ /**
+ * The event is a 'send' type of event
+ */
+ OUT,
+ }
+
+ /**
+ * Constructor with multiple traces and match processing object
+ *
+ * @param traces
+ * The set of traces for which to match events
+ */
+ public TmfNetworkEventMatching(ITmfTrace[] traces) {
+ this(traces, new TmfEventMatches());
+ }
+
+ /**
+ * Constructor with multiple traces and match processing object
+ *
+ * @param traces
+ * The set of traces for which to match events
+ * @param tmfEventMatches
+ * The match processing class
+ */
+ public TmfNetworkEventMatching(ITmfTrace[] traces, IMatchProcessingUnit tmfEventMatches) {
+ super(traces, tmfEventMatches);
+ }
+
+ /**
+ * Method that initializes any data structure for the event matching
+ */
+ @Override
+ public void initMatching() {
+ // Initialize the matching infrastructure (unmatched event lists)
+ fUnmatchedIn.clear();
+ fUnmatchedOut.clear();
+ for (int i = 0; i < getTraces().length; i++) {
+ fUnmatchedIn.add(new HashMap<List<Object>, ITmfEvent>());
+ fUnmatchedOut.add(new HashMap<List<Object>, ITmfEvent>());
+ }
+ super.initMatching();
+ }
+
+ /**
+ * Function that counts the events in a hashtable.
+ *
+ * @param tbl
+ * The table to count events for
+ * @return The number of events
+ */
+ protected int countEvents(Map<List<Object>, ITmfEvent> tbl) {
+ return tbl.size();
+ }
+
+ @Override
+ protected MatchingType getMatchingType() {
+ return MatchingType.NETWORK;
+ }
+
+ /**
+ * Matches one event
+ *
+ * @param event
+ * The event to match
+ * @param traceno
+ * The number of the trace this event belongs to
+ */
+ @Override
+ public void matchEvent(ITmfEvent event, int traceno) {
+ /*
+ * TODO: Should find a way to assert the type is right here. For now we
+ * just hope developers register NetworkMatchDefinition for Network
+ * match types...
+ */
+ TmfNetworkMatchDefinition def = (TmfNetworkMatchDefinition) getEventDefinition(event.getTrace());
+ if (def == null) {
+ return;
+ }
+
+ Direction evType = def.getDirection(event);
+ if (evType == null) {
+ return;
+ }
+
+ /* Get the event's unique fields */
+ List<Object> eventKey = def.getUniqueField(event);
+ List<Map<List<Object>, ITmfEvent>> unmatchedTbl, companionTbl;
+
+ /* Point to the appropriate table */
+ switch (evType) {
+ case IN:
+ unmatchedTbl = fUnmatchedIn;
+ companionTbl = fUnmatchedOut;
+ break;
+ case OUT:
+ unmatchedTbl = fUnmatchedOut;
+ companionTbl = fUnmatchedIn;
+ break;
+ default:
+ return;
+ }
+
+ boolean found = false;
+ TmfEventDependency dep = null;
+ /* Search for the event in the companion table */
+ for (Map<List<Object>, ITmfEvent> map : companionTbl) {
+ if (map.containsKey(eventKey)) {
+ found = true;
+ ITmfEvent companionEvent = map.get(eventKey);
+
+ /* Remove the element from the companion table */
+ map.remove(eventKey);
+
+ /* Create the dependency object */
+ switch (evType) {
+ case IN:
+ dep = new TmfEventDependency(companionEvent, event);
+ break;
+ case OUT:
+ dep = new TmfEventDependency(event, companionEvent);
+ break;
+ default:
+ break;
+
+ }
+ }
+ }
+
+ /*
+ * If no companion was found, add the event to the appropriate unMatched
+ * lists
+ */
+ if (found) {
+ getProcessingUnit().addMatch(dep);
+ } else {
+ /*
+ * If an event is already associated with this key, do not add it
+ * again, we keep the first event chronologically, so if its match
+ * is eventually found, it is associated with the first send or
+ * receive event. At best, it is a good guess, at worst, the match
+ * will be too far off to be accurate. Too bad!
+ *
+ * TODO: maybe instead of just one event, we could have a list of
+ * events as value for the unmatched table. Not necessary right now
+ * though
+ */
+ if (!unmatchedTbl.get(traceno).containsKey(eventKey)) {
+ unmatchedTbl.get(traceno).put(eventKey, event);
+ }
+ }
+
+ }
+
+ /**
+ * Prints stats from the matching
+ *
+ * @return string of statistics
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+ final String cr = System.getProperty("line.separator");
+ StringBuilder b = new StringBuilder();
+ b.append(getProcessingUnit());
+ for (int i = 0; i < getTraces().length; i++) {
+ b.append("Trace " + i + ":" + cr +
+ " " + countEvents(fUnmatchedIn.get(i)) + " unmatched incoming events" + cr +
+ " " + countEvents(fUnmatchedOut.get(i)) + " unmatched outgoing events" + cr);
+ }
+
+ return b.toString();
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event.matching;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfNetworkEventMatching.Direction;
+
+/**
+ * Base class for all network match definitions, ie traces with send and receive
+ * events
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public abstract class TmfNetworkMatchDefinition implements ITmfMatchEventDefinition {
+
+ /**
+ * Returns the direction of this event, whether 'send', 'receive' or null if
+ * event is neither
+ *
+ * @param event
+ * The event to check
+ * @return The direction of this event, null if uninteresting event
+ */
+ public abstract Direction getDirection(ITmfEvent event);
+
+}
*/
int getNbRequested();
- /**
- * @return the block size (for BG requests)
- */
- int getBlockSize();
-
/**
* @return the number of events read so far
*/
*
* Contributors:
* Francois Chouinard - Initial API and implementation
+ * Alexandre Montplaisir - Consolidated constructors
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.request;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
/**
- * TmfDataRequests are used to obtain blocks of contiguous data from a data provider. Open ranges can be used,
- * especially for continuous streaming.
+ * TmfDataRequests are used to obtain blocks of contiguous data from a data
+ * provider. Open ranges can be used, especially for continuous streaming.
* <p>
- * The request is processed asynchronously by a TmfProvider and, as blocks of data become available, handleData() is
- * invoked synchronously for each block. Upon return, the data instances go out of scope and become eligible for gc. It
- * is is thus the responsibility of the requester to either clone or keep a reference to the data it wishes to track
- * specifically.
+ * The request is processed asynchronously by a TmfProvider and, as blocks of
+ * data become available, handleData() is invoked synchronously for each block.
+ * Upon return, the data instances go out of scope and become eligible for gc.
+ * It is is thus the responsibility of the requester to either clone or keep a
+ * reference to the data it wishes to track specifically.
* <p>
- * This data block approach is used to avoid busting the heap for very large trace files. The block size is
- * configurable.
+ * This data block approach is used to avoid busting the heap for very large
+ * trace files. The block size is configurable.
* <p>
- * The TmfProvider indicates that the request is completed by calling done(). The request can be canceled at any time
- * with cancel().
+ * The TmfProvider indicates that the request is completed by calling done().
+ * The request can be canceled at any time with cancel().
* <p>
* Typical usage:
*
* </i></code>
* </pre>
*
- * TODO: Consider decoupling from "time range", "rank", etc and for the more generic notion of "criteria". This would
- * allow to extend for "time range", etc instead of providing specialized constructors. This also means removing the
- * criteria info from the data structure (with the possible exception of fNbRequested). The nice thing about it is that
- * it would prepare us well for the coming generation of analysis tools.
+ * TODO: Consider decoupling from "time range", "rank", etc and for the more
+ * generic notion of "criteria". This would allow to extend for "time range",
+ * etc instead of providing specialized constructors. This also means removing
+ * the criteria info from the data structure (with the possible exception of
+ * fNbRequested). The nice thing about it is that it would prepare us well for
+ * the coming generation of analysis tools.
*
* TODO: Implement request failures (codes, etc...)
*
// Constants
// ------------------------------------------------------------------------
- /** The default maximum number of events per chunk */
- public static final int DEFAULT_BLOCK_SIZE = 1000;
-
/** The request count for all the events */
public static final int ALL_DATA = Integer.MAX_VALUE;
/** The number of requested events (ALL_DATA for all) */
protected int fNbRequested;
- /** The block size (for BG requests) */
- private final int fBlockSize;
-
/** The number of reads so far */
private int fNbRead;
fRequestNumber = 0;
}
- /**
- * Request all the events of a given type (high priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- */
- public TmfDataRequest(Class<? extends ITmfEvent> dataType) {
- this(dataType, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
- }
-
- /**
- * Request all the events of a given type (given priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param priority the requested execution priority
- */
- public TmfDataRequest(Class<? extends ITmfEvent> dataType, ExecutionType priority) {
- this(dataType, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, priority);
- }
-
- /**
- * Request all the events of a given type from the given index (high priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param index the index of the first event to retrieve
- */
- public TmfDataRequest(Class<? extends ITmfEvent> dataType, long index) {
- this(dataType, index, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
- }
-
- /**
- * Request all the events of a given type from the given index (given priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param index the index of the first event to retrieve
- * @param priority the requested execution priority
- */
- public TmfDataRequest(Class<? extends ITmfEvent> dataType, long index, ExecutionType priority) {
- this(dataType, index, ALL_DATA, DEFAULT_BLOCK_SIZE, priority);
- }
-
- /**
- * Request 'n' events of a given type from the given index (high priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param index the index of the first event to retrieve
- * @param nbRequested the number of events requested
- */
- public TmfDataRequest(Class<? extends ITmfEvent> dataType, long index, int nbRequested) {
- this(dataType, index, nbRequested, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
- }
-
- /**
- * Request 'n' events of a given type from the given index (given priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param index the index of the first event to retrieve
- * @param nbRequested the number of events requested
- * @param priority the requested execution priority
- */
- public TmfDataRequest(Class<? extends ITmfEvent> dataType, long index, int nbRequested, ExecutionType priority) {
- this(dataType, index, nbRequested, DEFAULT_BLOCK_SIZE, priority);
- }
-
- /**
- * Request 'n' events of a given type from the given index (high priority).
- * Events are returned in blocks of the given size.
- *
- * @param dataType the requested data type
- * @param index the index of the first event to retrieve
- * @param nbRequested the number of events requested
- * @param blockSize the number of events per block
- */
- public TmfDataRequest(Class<? extends ITmfEvent> dataType, long index, int nbRequested, int blockSize) {
- this(dataType, index, nbRequested, blockSize, ExecutionType.FOREGROUND);
- }
-
/**
* Request 'n' events of a given type from the given index (given priority).
* Events are returned in blocks of the given size.
*
- * @param dataType the requested data type
- * @param index the index of the first event to retrieve
- * @param nbRequested the number of events requested
- * @param blockSize the number of events per block
- * @param priority the requested execution priority
+ * @param dataType
+ * The requested data type.
+ * @param index
+ * The index of the first event to retrieve. Use '0' to start at
+ * the beginning of the trace.
+ * @param nbRequested
+ * The number of events requested. You can use
+ * {@link TmfDataRequest#ALL_DATA} to specify you want all events
+ * in the trace.
+ * @param priority
+ * The requested execution priority.
*/
- public TmfDataRequest(Class<? extends ITmfEvent> dataType, long index, int nbRequested, int blockSize, ExecutionType priority) {
+ public TmfDataRequest(Class<? extends ITmfEvent> dataType,
+ long index,
+ int nbRequested,
+ ExecutionType priority) {
fRequestId = fRequestNumber++;
fDataType = dataType;
fIndex = index;
fNbRequested = nbRequested;
- fBlockSize = blockSize;
fExecType = priority;
fNbRead = 0;
return fNbRequested;
}
- /**
- * @return the block size (for BG requests)
- */
- @Override
- public int getBlockSize() {
- return fBlockSize;
- }
-
/**
* @return the number of events read so far
*/
name = name.substring(dot + 1);
}
return "[" + name + "(" + fRequestId + "," + fDataType.getSimpleName()+ "," + getExecType()
- + "," + fIndex + "," + fNbRequested + "," + getBlockSize() + ")]";
+ + "," + fIndex + "," + fNbRequested + ")]";
}
}
*
* Contributors:
* Francois Chouinard - Initial API and implementation
+ * Alexandre Montplaisir - Consolidated constructors
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.request;
// Attributes
// ------------------------------------------------------------------------
- private final TmfTimeRange fRange; // The requested events time range
+ private final TmfTimeRange fRange; // The requested events time range
// ------------------------------------------------------------------------
- // Constructors
+ // Constructor
// ------------------------------------------------------------------------
/**
- * Request all the events of a given type (high priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
+ * Request 'n' events of a given type for the given time range (given
+ * priority). Events are returned in blocks of the given size.
*
- * @param dataType the requested data type
+ * @param dataType
+ * The requested data type.
+ * @param range
+ * The time range of the requested events. You can use
+ * {@link TmfTimeRange#ETERNITY} to indicate you want to cover
+ * the whole trace.
+ * @param index
+ * The index of the first event to retrieve. You can use '0' to
+ * start at the beginning of the trace.
+ * @param nbRequested
+ * The number of events requested. You can use
+ * {@link TmfEventRequest#ALL_DATA} to indicate you want all
+ * events in the time range.
+ * @param priority
+ * The requested execution priority.
+ * @since 3.0
*/
- public TmfEventRequest(Class<? extends ITmfEvent> dataType) {
- this(dataType, TmfTimeRange.ETERNITY, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
- }
-
- /**
- * Request all the events of a given type (given priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param priority the requested execution priority
- */
- public TmfEventRequest(Class<? extends ITmfEvent> dataType, ExecutionType priority) {
- this(dataType, TmfTimeRange.ETERNITY, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, priority);
- }
-
- /**
- * Request all the events of a given type for the given time range (high priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param range the time range of the requested events
- */
- public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range) {
- this(dataType, range, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
- }
-
- /**
- * Request all the events of a given type for the given time range (given priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param range the time range of the requested events
- * @param priority the requested execution priority
- */
- public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, ExecutionType priority) {
- this(dataType, range, 0, ALL_DATA, DEFAULT_BLOCK_SIZE, priority);
- }
-
- /**
- * Request 'n' events of a given type from the given time range (high priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param range the time range of the requested events
- * @param nbRequested the number of events requested
- */
- public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, int nbRequested) {
- this(dataType, range, 0, nbRequested, DEFAULT_BLOCK_SIZE, ExecutionType.FOREGROUND);
- }
-
- /**
- * Request 'n' events of a given type for the given time range (given priority)
- * Events are returned in blocks of the default size (DEFAULT_BLOCK_SIZE).
- *
- * @param dataType the requested data type
- * @param range the time range of the requested events
- * @param nbRequested the number of events requested
- * @param priority the requested execution priority
- */
- public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, int nbRequested, ExecutionType priority) {
- this(dataType, range, 0, nbRequested, DEFAULT_BLOCK_SIZE, priority);
- }
-
- /**
- * Request 'n' events of a given type for the given time range (high priority).
- * Events are returned in blocks of the given size.
- *
- * @param dataType the requested data type
- * @param range the time range of the requested events
- * @param nbRequested the number of events requested
- * @param blockSize the number of events per block
- */
- public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, int nbRequested, int blockSize) {
- this(dataType, range, 0, nbRequested, blockSize, ExecutionType.FOREGROUND);
- }
-
- /**
- * Request 'n' events of a given type for the given time range (high priority).
- * Events are returned in blocks of the given size.
- *
- * @param dataType the requested data type
- * @param range the time range of the requested events
- * @param index the index of the first event to retrieve
- * @param nbRequested the number of events requested
- * @param blockSize the number of events per block
- */
- public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, long index, int nbRequested, int blockSize) {
- this(dataType, range, index, nbRequested, blockSize, ExecutionType.FOREGROUND);
- }
-
- /**
- * Request 'n' events of a given type for the given time range (given priority).
- * Events are returned in blocks of the given size.
- *
- * @param dataType the requested data type
- * @param range the time range of the requested events
- * @param nbRequested the number of events requested
- * @param blockSize the number of events per block
- * @param priority the requested execution priority
- */
- public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, int nbRequested, int blockSize, ExecutionType priority) {
- this(dataType, range, 0, nbRequested, blockSize, priority);
- }
-
- /**
- * Request 'n' events of a given type for the given time range (given priority).
- * Events are returned in blocks of the given size.
- *
- * @param dataType the requested data type
- * @param range the time range of the requested events
- * @param index the index of the first event to retrieve
- * @param nbRequested the number of events requested
- * @param blockSize the number of events per block
- * @param priority the requested execution priority
- */
- public TmfEventRequest(Class<? extends ITmfEvent> dataType, TmfTimeRange range, long index, int nbRequested, int blockSize, ExecutionType priority) {
- super(dataType, index, nbRequested, blockSize, priority);
- fRange = range;
+ public TmfEventRequest(Class<? extends ITmfEvent> dataType,
+ TmfTimeRange range,
+ long index,
+ int nbRequested,
+ ExecutionType priority) {
+ super(dataType, index, nbRequested, priority);
+ fRange = range;
if (TmfCoreTracer.isRequestTraced()) {
String type = getClass().getName();
* @since 2.0
*/
@Override
- public TmfTimeRange getRange() {
+ public TmfTimeRange getRange() {
return fRange;
}
// ------------------------------------------------------------------------
/**
- * this method is called by the event provider to set the index corresponding
- * to the time range start time once it is known
+ * this method is called by the event provider to set the index
+ * corresponding to the time range start time once it is known
*
- * @param index the start index
+ * @param index
+ * the start index
*/
@Override
- public void setStartIndex(int index) {
- setIndex(index);
+ public void setStartIndex(int index) {
+ setIndex(index);
}
// ------------------------------------------------------------------------
@Override
// All requests have a unique id
public int hashCode() {
- return getRequestId();
+ return getRequestId();
}
@Override
public boolean equals(Object other) {
- if (other instanceof TmfEventRequest) {
- TmfEventRequest request = (TmfEventRequest) other;
- return super.equals(other) && request.fRange.equals(fRange);
- }
- return false;
+ if (other instanceof TmfEventRequest) {
+ TmfEventRequest request = (TmfEventRequest) other;
+ return super.equals(other) && request.fRange.equals(fRange);
+ }
+ return false;
}
@Override
name = name.substring(dot + 1);
}
return "[" + name + "(" + getRequestId() + "," + getDataType().getSimpleName() + "," + getExecType()
- + "," + getRange() + "," + getIndex() + "," + getNbRequested() + "," + getBlockSize() + ")]";
+ + "," + getRange() + "," + getIndex() + "," + getNbRequested() + ")]";
}
}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.signal;
+
+import org.eclipse.linuxtools.tmf.core.synchronization.SynchronizationAlgorithm;
+
+/**
+ * Signal indicating a trace synchronization has been done
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public class TmfTraceSynchronizedSignal extends TmfSignal {
+
+ private final SynchronizationAlgorithm fAlgoSync;
+
+ /**
+ * Constructor
+ *
+ * @param source
+ * Object sending this signal
+ * @param algoSync
+ * The synchronization algorithm used
+ */
+ public TmfTraceSynchronizedSignal(Object source, SynchronizationAlgorithm algoSync) {
+ super(source);
+ fAlgoSync = algoSync;
+ }
+
+ /**
+ * Synchronization algorithm getter
+ *
+ * @return The algorithm object
+ */
+ public SynchronizationAlgorithm getSyncAlgo() {
+ return fAlgoSync;
+ }
+
+ @Override
+ public String toString() {
+ return "[" + getClass().getSimpleName() + " (" + fAlgoSync.toString() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+}
private long total;
public StatsTotalRequest(ITmfTrace trace, TmfTimeRange range) {
- super(trace.getEventType(), range, TmfDataRequest.ALL_DATA,
- trace.getCacheSize(), ITmfDataRequest.ExecutionType.BACKGROUND);
+ super(trace.getEventType(), range, 0, TmfDataRequest.ALL_DATA,
+ ITmfDataRequest.ExecutionType.BACKGROUND);
total = 0;
}
private final Map<String, Long> stats;
public StatsPerTypeRequest(ITmfTrace trace, TmfTimeRange range) {
- super(trace.getEventType(), range, TmfDataRequest.ALL_DATA,
- trace.getCacheSize(), ITmfDataRequest.ExecutionType.BACKGROUND);
+ super(trace.getEventType(), range, 0, TmfDataRequest.ALL_DATA,
+ ITmfDataRequest.ExecutionType.BACKGROUND);
this.stats = new HashMap<String, Long>();
}
new TmfTimeRange(
new TmfTimestamp(borders[0], SCALE),
new TmfTimestamp(endTime, SCALE)),
+ 0,
TmfDataRequest.ALL_DATA,
- trace.getCacheSize(),
ITmfDataRequest.ExecutionType.BACKGROUND);
/* Prepare the results map, with all counts at 0 */
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.synchronization;
+
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+
+/**
+ * This class contains a formula to transform the value of a timestamp, for
+ * example after trace synchronization
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public interface ITmfTimestampTransform {
+
+ /**
+ * Transforms a timestamp
+ *
+ * @param timestamp
+ * The timestamp to transform
+ * @return the transformed timestamp
+ */
+ ITmfTimestamp transform(ITmfTimestamp timestamp);
+
+ /**
+ * Transforms a timestamp value
+ *
+ * @param timestamp
+ * The timestamp to transform
+ * @return the transformed value
+ */
+ long transform(long timestamp);
+
+ /**
+ * Returns a timestamp transform that is the composition of two timestamp
+ * transforms.
+ *
+ * @param composeWith
+ * The transform to first apply on the timestamp before applying
+ * the current object
+ * @return A new timestamp transform object with the resulting composition.
+ */
+ ITmfTimestampTransform composeWith(ITmfTimestampTransform composeWith);
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.synchronization;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Messages class
+ *
+ * @since 3.0
+ */
+@SuppressWarnings("javadoc")
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.core.synchronization.messages"; //$NON-NLS-1$
+ public static String SyncAlgorithmFullyIncremental_absent;
+ public static String SyncAlgorithmFullyIncremental_alpha;
+ public static String SyncAlgorithmFullyIncremental_beta;
+ public static String SyncAlgorithmFullyIncremental_T_;
+ public static String SyncAlgorithmFullyIncremental_otherformula;
+ public static String SyncAlgorithmFullyIncremental_mult;
+ public static String SyncAlgorithmFullyIncremental_add;
+ public static String SyncAlgorithmFullyIncremental_ub;
+ public static String SyncAlgorithmFullyIncremental_lb;
+ public static String SyncAlgorithmFullyIncremental_accuracy;
+ public static String SyncAlgorithmFullyIncremental_accurate;
+ public static String SyncAlgorithmFullyIncremental_approx;
+ public static String SyncAlgorithmFullyIncremental_fail;
+ public static String SyncAlgorithmFullyIncremental_incomplete;
+ public static String SyncAlgorithmFullyIncremental_nbmatch;
+ public static String SyncAlgorithmFullyIncremental_nbacc;
+ public static String SyncAlgorithmFullyIncremental_reftrace;
+ public static String SyncAlgorithmFullyIncremental_othertrace;
+ public static String SyncAlgorithmFullyIncremental_refformula;
+ public static String SyncAlgorithmFullyIncremental_NA;
+ public static String SyncAlgorithmFullyIncremental_quality;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.synchronization;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.MathContext;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventDependency;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * Class implementing fully incremental trace synchronization approach as
+ * described in
+ *
+ * Masoume Jabbarifar, Michel Dagenais and Alireza Shameli-Sendi,
+ * "Streaming Mode Incremental Clock Synchronization"
+ *
+ * Since the algorithm itself applies to two traces, it is implemented in a
+ * private class, while this public class manages the synchronization between
+ * all traces.
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public class SyncAlgorithmFullyIncremental extends SynchronizationAlgorithm {
+
+ /**
+ * Auto-generated serial UID
+ */
+ private static final long serialVersionUID = -1782788842774838830L;
+
+ private static final MathContext fMc = MathContext.DECIMAL128;
+
+ private final List<ConvexHull> fSyncs;
+
+ /**
+ * Initialization of the attributes
+ */
+ public SyncAlgorithmFullyIncremental() {
+ fSyncs = new LinkedList<ConvexHull>();
+ }
+
+ /**
+ * Function called after all matching has been done, to do any post-match
+ * treatment. For this class, it calculates stats, while the data is
+ * available
+ */
+ @Override
+ public void matchingEnded() {
+ getStats();
+ }
+
+ @Override
+ public void init(ITmfTrace[] fTraces) {
+ fSyncs.clear();
+ /* Create a convex hull for all trace pairs */
+ for (int i = 0; i < fTraces.length; i++) {
+ for (int j = i + 1; j < fTraces.length; j++) {
+ ConvexHull algo = new ConvexHull(fTraces[i].getName(), fTraces[j].getName());
+ fSyncs.add(algo);
+ }
+ }
+ }
+
+ @Override
+ protected void processMatch(TmfEventDependency match) {
+ String trace1 = match.getSourceEvent().getTrace().getName();
+ String trace2 = match.getDestinationEvent().getTrace().getName();
+
+ /* Process only if source and destination are different */
+ if (trace1.equals(trace2)) {
+ return;
+ }
+
+ /* Check if a convex hull algorithm already exists for these 2 traces */
+ ConvexHull algo = null;
+ for (ConvexHull traceSync : fSyncs) {
+ if (traceSync.isForTraces(trace1, trace2)) {
+ algo = traceSync;
+ }
+ }
+ if (algo == null) {
+ algo = new ConvexHull(trace1, trace2);
+ fSyncs.add(algo);
+ }
+ algo.processMatch(match);
+
+ }
+
+ @Override
+ public ITmfTimestampTransform getTimestampTransform(ITmfTrace trace) {
+ return getTimestampTransform(trace.getName());
+ }
+
+ @Override
+ public ITmfTimestampTransform getTimestampTransform(String name) {
+ for (ConvexHull traceSync : fSyncs) {
+ if (traceSync.isTraceSynced(name)) {
+ /*
+ * Since there are many traces, maybe the reference trace is
+ * also synchronized, so we need to chain sync formulas
+ */
+ ITmfTimestampTransform refTt = getTimestampTransform(traceSync.getReferenceTrace());
+ return refTt.composeWith(traceSync.getTimestampTransform(name));
+ }
+ }
+ return TmfTimestampTransform.IDENTITY;
+ }
+
+ @Override
+ public SyncQuality getSynchronizationQuality(ITmfTrace trace1, ITmfTrace trace2) {
+ for (ConvexHull traceSync : fSyncs) {
+ if (traceSync.isForTraces(trace1.getName(), trace2.getName())) {
+ return traceSync.getQuality();
+ }
+ }
+ return SyncQuality.ABSENT;
+ }
+
+ @Override
+ public boolean isTraceSynced(String name) {
+ boolean traceSynced = false;
+ for (ConvexHull traceSync : fSyncs) {
+ traceSynced = traceSynced || traceSync.isTraceSynced(name);
+ }
+ return traceSynced;
+ }
+
+ /**
+ * Rename one of the traces in the synchronization
+ *
+ * @param oldname
+ * The name of the original trace
+ * @param newname
+ * The new name of the trace
+ */
+ @Override
+ public void renameTrace(String oldname, String newname) {
+ for (ConvexHull traceSync : fSyncs) {
+ traceSync.renameTrace(oldname, newname);
+ }
+ }
+
+ @Override
+ public Map<String, Map<String, Object>> getStats() {
+ Map<String, Map<String, Object>> statmap = new LinkedHashMap<String, Map<String, Object>>();
+ for (ConvexHull traceSync : fSyncs) {
+ statmap.put(traceSync.getReferenceTrace() + " <==> " + traceSync.getOtherTrace(), traceSync.getStats()); //$NON-NLS-1$
+ }
+ return statmap;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder b = new StringBuilder();
+ b.append(getClass().getSimpleName() + " "); //$NON-NLS-1$
+ b.append(fSyncs);
+ return b.toString();
+ }
+
+ /**
+ * This is the actual synchronization algorithm between two traces using
+ * convex hull
+ */
+ private class ConvexHull implements Serializable {
+
+ private static final long serialVersionUID = 8309351175030935291L;
+
+ /**
+ * The list of meaningful points on the upper hull (received by the
+ * reference trace, below in a graph)
+ */
+ private final LinkedList<SyncPoint> fUpperBoundList = new LinkedList<SyncPoint>();
+
+ /**
+ * The list of meaninful points on the lower hull (sent by the reference
+ * trace, above in a graph)
+ */
+ private final LinkedList<SyncPoint> fLowerBoundList = new LinkedList<SyncPoint>();
+
+ /** Points forming the line with maximum slope */
+ private final SyncPoint[] fLmax;
+
+ /** Points forming the line with minimum slope */
+ private final SyncPoint[] fLmin;
+
+ /**
+ * Slopes and ordinate at origin of respectively fLmin, fLmax and the
+ * bisector
+ */
+ private BigDecimal fAlphamin, fBetamax, fAlphamax, fBetamin, fAlpha, fBeta;
+
+ private int fNbMatches, fNbAccurateMatches;
+ private String fReferenceTrace = "", fOtherTrace = ""; //$NON-NLS-1$//$NON-NLS-2$
+ private SyncQuality fQuality;
+
+ private Map<String, Object> fStats = new LinkedHashMap<String, Object>();
+
+ /**
+ * Initialization of the attributes
+ *
+ * @param trace1
+ * Name of the first trace
+ * @param trace2
+ * Name of the second trace
+ */
+ public ConvexHull(String trace1, String trace2) {
+ if (trace1.compareTo(trace2) > 0) {
+ fReferenceTrace = trace2;
+ fOtherTrace = trace1;
+ } else {
+ fReferenceTrace = trace1;
+ fOtherTrace = trace2;
+ }
+ fLmax = new SyncPoint[2];
+ fLmin = new SyncPoint[2];
+ fAlpha = BigDecimal.ONE;
+ fAlphamax = BigDecimal.ONE;
+ fAlphamin = BigDecimal.ONE;
+ fBeta = BigDecimal.ZERO;
+ fBetamax = BigDecimal.ZERO;
+ fBetamin = BigDecimal.ZERO;
+ fNbMatches = 0;
+ fNbAccurateMatches = 0;
+ fQuality = SyncQuality.ABSENT;
+ }
+
+ protected void processMatch(TmfEventDependency match) {
+
+ LinkedList<SyncPoint> boundList, otherBoundList;
+
+ SyncPoint[] line, otherLine;
+ SyncPoint p;
+ int inversionFactor = 1;
+ boolean qualify = false;
+ fNbMatches++;
+
+ /* Initialize data depending on the which hull the match is part of */
+ if (match.getSourceEvent().getTrace().getName().compareTo(match.getDestinationEvent().getTrace().getName()) > 0) {
+ boundList = fUpperBoundList;
+ otherBoundList = fLowerBoundList;
+ line = fLmin;
+ otherLine = fLmax;
+ p = new SyncPoint(match.getDestinationEvent(), match.getSourceEvent());
+ inversionFactor = 1;
+ } else {
+ boundList = fLowerBoundList;
+ otherBoundList = fUpperBoundList;
+ line = fLmax;
+ otherLine = fLmin;
+ p = new SyncPoint(match.getSourceEvent(), match.getDestinationEvent());
+ inversionFactor = -1;
+ }
+
+ /*
+ * Does the message qualify for the hull, or is in on the wrong side
+ * of the reference line
+ */
+ if ((line[0] == null) || (line[1] == null) || (p.crossProduct(line[0], line[1]) * inversionFactor > 0)) {
+ /*
+ * If message qualifies, verify if points need to be removed
+ * from the hull and add the new point as the maximum reference
+ * point for the line. Also clear the stats that are not good
+ * anymore
+ */
+ fNbAccurateMatches++;
+ qualify = true;
+ removeUselessPoints(p, boundList, inversionFactor);
+ line[1] = p;
+ fStats.clear();
+ }
+
+ /*
+ * Adjust the boundary of the reference line and if one of the
+ * reference point of the other line was removed from the hull, also
+ * adjust the other line
+ */
+ adjustBound(line, otherBoundList, inversionFactor);
+ if ((otherLine[1] != null) && !boundList.contains(otherLine[0])) {
+ adjustBound(otherLine, boundList, inversionFactor * -1);
+ }
+
+ if (qualify) {
+ approximateSync();
+ }
+
+ }
+
+ /**
+ * Calculates slopes and ordinate at origin of fLmax and fLmin to obtain
+ * and approximation of the synchronization at this time
+ */
+ private void approximateSync() {
+ /**
+ * Line slopes functions
+ *
+ * Lmax = alpha_max T + beta_min
+ *
+ * Lmin = alpha_min T + beta_max
+ */
+ if ((fLmax[0] != null) || (fLmin[0] != null)) {
+ fAlphamax = fLmax[1].getAlpha(fLmax[0]);
+ fBetamin = fLmax[1].getBeta(fAlphamax);
+ fAlphamin = fLmin[1].getAlpha(fLmin[0]);
+ fBetamax = fLmin[1].getBeta(fAlphamin);
+ fAlpha = fAlphamax.add(fAlphamin).divide(BigDecimal.valueOf(2), fMc);
+ fBeta = fBetamin.add(fBetamax).divide(BigDecimal.valueOf(2), fMc);
+ if ((fLmax[0] == null) || (fLmin[0] == null)) {
+ fQuality = SyncQuality.APPROXIMATE;
+ }
+ else if (fAlphamax.compareTo(fAlphamin) > 0) {
+ fQuality = SyncQuality.ACCURATE;
+ } else {
+ /* Lines intersect, not good */
+ fQuality = SyncQuality.FAIL;
+ }
+ } else if (((fLmax[0] == null) && (fLmin[1] == null))
+ || ((fLmax[1] == null) && (fLmin[0] == null))) {
+ /* Either there is no upper hull point or no lower hull */
+ fQuality = SyncQuality.INCOMPLETE;
+ }
+ }
+
+ /*
+ * Verify if the line should be adjusted to be more accurate give the
+ * hull
+ */
+ private void adjustBound(SyncPoint[] line, LinkedList<SyncPoint> otherBoundList, int inversionFactor) {
+ SyncPoint minPoint = null, nextPoint;
+ boolean finishedSearch = false;
+
+ /*
+ * Find in the other bound, the origin point of the line, start from
+ * the beginning if the point was lost
+ */
+ int i = Math.max(0, otherBoundList.indexOf(line[0]));
+
+ while ((i < otherBoundList.size() - 1) && !finishedSearch) {
+ minPoint = otherBoundList.get(i);
+ nextPoint = otherBoundList.get(i + 1);
+
+ /*
+ * If the rotation (cross-product) is not optimal, move to next
+ * point as reference for the line (if available)
+ *
+ * Otherwise, the current minPoint is the minPoint of the line
+ */
+ if (minPoint.crossProduct(nextPoint, line[1]) * inversionFactor > 0) {
+ if (nextPoint.getTimeX() < line[1].getTimeX()) {
+ i++;
+ } else {
+ line[0] = null;
+ finishedSearch = true;
+ }
+ } else {
+ line[0] = minPoint;
+ finishedSearch = true;
+ }
+ }
+
+ if (line[0] == null) {
+ line[0] = minPoint;
+ }
+
+ /* Make sure point 0 is before point 1 */
+ if ((line[0] != null) && (line[0].getTimeX() > line[1].getTimeX())) {
+ line[0] = null;
+ }
+ }
+
+ /*
+ * When a point qualifies to be in a hull, we verify if any of the
+ * existing points need to be removed from the hull
+ */
+ private void removeUselessPoints(final SyncPoint p, final LinkedList<SyncPoint> boundList, final int inversionFactor) {
+
+ boolean checkRemove = true;
+
+ while (checkRemove && boundList.size() >= 2) {
+ if (p.crossProduct(boundList.get(boundList.size() - 2), boundList.getLast()) * inversionFactor > 0) {
+ boundList.removeLast();
+ } else {
+ checkRemove = false;
+ }
+ }
+ boundList.addLast(p);
+ }
+
+ public ITmfTimestampTransform getTimestampTransform(String name) {
+ if (name.equals(fOtherTrace) && (fQuality == SyncQuality.ACCURATE || fQuality == SyncQuality.APPROXIMATE || fQuality == SyncQuality.FAIL)) {
+ /* alpha: beta => 1 / fAlpha, -1 * fBeta / fAlpha); */
+ return new TmfTimestampTransformLinear(BigDecimal.ONE.divide(fAlpha, fMc), BigDecimal.valueOf(-1).multiply(fBeta).divide(fAlpha, fMc));
+ }
+ return TmfTimestampTransform.IDENTITY;
+ }
+
+ public SyncQuality getQuality() {
+ return fQuality;
+ }
+
+ public Map<String, Object> getStats() {
+ if (fStats.size() == 0) {
+ String syncQuality;
+ switch (fQuality) {
+ case ABSENT:
+ syncQuality = Messages.SyncAlgorithmFullyIncremental_absent;
+ break;
+ case ACCURATE:
+ syncQuality = Messages.SyncAlgorithmFullyIncremental_accurate;
+ break;
+ case APPROXIMATE:
+ syncQuality = Messages.SyncAlgorithmFullyIncremental_approx;
+ break;
+ case INCOMPLETE:
+ syncQuality = Messages.SyncAlgorithmFullyIncremental_incomplete;
+ break;
+ case FAIL:
+ default:
+ syncQuality = Messages.SyncAlgorithmFullyIncremental_fail;
+ break;
+ }
+
+ fStats.put(Messages.SyncAlgorithmFullyIncremental_reftrace, fReferenceTrace);
+ fStats.put(Messages.SyncAlgorithmFullyIncremental_othertrace, fOtherTrace);
+ fStats.put(Messages.SyncAlgorithmFullyIncremental_quality, syncQuality);
+ fStats.put(Messages.SyncAlgorithmFullyIncremental_alpha, fAlpha);
+ fStats.put(Messages.SyncAlgorithmFullyIncremental_beta, fBeta);
+ fStats.put(Messages.SyncAlgorithmFullyIncremental_ub, (fUpperBoundList.size() == 0) ? Messages.SyncAlgorithmFullyIncremental_NA : fUpperBoundList.size());
+ fStats.put(Messages.SyncAlgorithmFullyIncremental_lb, (fLowerBoundList.size() == 0) ? Messages.SyncAlgorithmFullyIncremental_NA : fLowerBoundList.size());
+ fStats.put(Messages.SyncAlgorithmFullyIncremental_accuracy, fAlphamax.subtract(fAlphamin).doubleValue()); // -
+ // fAlphamin);
+ fStats.put(Messages.SyncAlgorithmFullyIncremental_nbmatch, (fNbMatches == 0) ? Messages.SyncAlgorithmFullyIncremental_NA : fNbMatches);
+ fStats.put(Messages.SyncAlgorithmFullyIncremental_nbacc, (fNbAccurateMatches == 0) ? Messages.SyncAlgorithmFullyIncremental_NA : fNbAccurateMatches);
+ fStats.put(Messages.SyncAlgorithmFullyIncremental_refformula, Messages.SyncAlgorithmFullyIncremental_T_ + fReferenceTrace);
+ fStats.put(Messages.SyncAlgorithmFullyIncremental_otherformula, fAlpha + Messages.SyncAlgorithmFullyIncremental_mult + Messages.SyncAlgorithmFullyIncremental_T_ + fReferenceTrace + Messages.SyncAlgorithmFullyIncremental_add + fBeta);
+ }
+ return fStats;
+
+ }
+
+ public String getReferenceTrace() {
+ return fReferenceTrace;
+ }
+
+ public String getOtherTrace() {
+ return fOtherTrace;
+ }
+
+ public boolean isTraceSynced(String name) {
+ /* Returns true if the timestamp transform is not identity */
+ return (name.equals(fOtherTrace) && (fQuality == SyncQuality.ACCURATE || fQuality == SyncQuality.APPROXIMATE || fQuality == SyncQuality.FAIL));
+ }
+
+ public boolean isForTraces(String trace1, String trace2) {
+ return ((fReferenceTrace.equals(trace1) && fOtherTrace.equals(trace2)) || (fReferenceTrace.equals(trace2) && fOtherTrace.equals(trace1)));
+ }
+
+ public void renameTrace(String oldname, String newname) {
+ if (oldname.equals(fOtherTrace)) {
+ fOtherTrace = newname;
+ } else if (oldname.equals(fReferenceTrace)) {
+ fReferenceTrace = newname;
+ }
+ }
+
+ private void writeObject(ObjectOutputStream s)
+ throws IOException {
+ /*
+ * Remove calculation data because most of it is not serializable.
+ * We have the statistics anyway
+ */
+ fUpperBoundList.clear();
+ fLowerBoundList.clear();
+ fLmin[0] = null;
+ fLmin[1] = null;
+ fLmax[0] = null;
+ fLmax[1] = null;
+ s.defaultWriteObject();
+
+ }
+
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+ StringBuilder b = new StringBuilder();
+ b.append("Between " + fReferenceTrace + " and " + fOtherTrace + " [");
+ b.append(" alpha " + fAlpha + " beta " + fBeta + " ]");
+ return b.toString();
+ }
+ }
+
+ /**
+ * Private class representing a point to synchronize on a graph. The x axis
+ * is the timestamp of the event from the reference trace while the y axis
+ * is the timestamp of the event on the other trace
+ */
+ private class SyncPoint {
+ private final ITmfTimestamp x, y;
+
+ public SyncPoint(ITmfEvent ex, ITmfEvent ey) {
+ x = ex.getTimestamp();
+ y = ey.getTimestamp();
+ }
+
+ public long getTimeX() {
+ return x.getValue();
+ }
+
+ /**
+ * Calculate a cross product of 3 points:
+ *
+ * If the cross-product < 0, then p, pa, pb are clockwise
+ *
+ * If the cross-product > 0, then p, pa, pb are counter-clockwise
+ *
+ * If cross-product == 0, then they are in a line
+ *
+ * @param pa
+ * First point
+ * @param pb
+ * Second point
+ * @return The cross product
+ */
+ public long crossProduct(SyncPoint pa, SyncPoint pb) {
+ long cp = ((pa.x.getValue() - x.getValue()) * (pb.y.getValue() - y.getValue()) - (pa.y.getValue() - y.getValue()) * (pb.x.getValue() - x.getValue()));
+ return cp;
+ }
+
+ /*
+ * Gets the alpha (slope) between two points
+ */
+ public BigDecimal getAlpha(SyncPoint p1) {
+ if (p1 == null) {
+ return BigDecimal.ONE;
+ }
+ BigDecimal deltay = BigDecimal.valueOf(y.getValue() - p1.y.getValue());
+ BigDecimal deltax = BigDecimal.valueOf(x.getValue() - p1.x.getValue());
+ if (deltax.equals(BigDecimal.ZERO)) {
+ return BigDecimal.ONE;
+ }
+ return deltay.divide(deltax, fMc);
+ }
+
+ /*
+ * Get the beta value (when x = 0) of the line given alpha
+ */
+ public BigDecimal getBeta(BigDecimal alpha) {
+ return BigDecimal.valueOf(y.getValue()).subtract(alpha.multiply(BigDecimal.valueOf(x.getValue()), fMc));
+ }
+
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.synchronization;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventDependency;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventMatches;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * Abstract class for synchronization algorithm
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public abstract class SynchronizationAlgorithm extends TmfEventMatches implements Serializable {
+
+ private static final long serialVersionUID = -3083906749528872196L;
+
+ /**
+ * Quality of the result obtained by the synchronization algorithm
+ */
+ public enum SyncQuality {
+ /**
+ * Algorithm returned a result satisfying all hypothesis for the
+ * algorithm
+ */
+ ACCURATE,
+ /**
+ * Best effort of the algorithm
+ */
+ APPROXIMATE,
+ /**
+ * There is communication only in one direction
+ */
+ INCOMPLETE,
+ /**
+ * No communication between two traces
+ */
+ ABSENT,
+ /**
+ * Hypothesis of the algorithm are not satisfied for some reason
+ */
+ FAIL
+ }
+
+ @Override
+ public void addMatch(TmfEventDependency match) {
+ super.addMatch(match);
+ processMatch(match);
+ }
+
+ /**
+ * Function for synchronization algorithm to do something with the received
+ * match
+ *
+ * @param match
+ * The match of events
+ */
+ protected abstract void processMatch(TmfEventDependency match);
+
+ /**
+ * Returns a map of staticstics relating to this algorithm. Those stats
+ * could be used to be displayed in a view for example.
+ *
+ * @return A map of statistics for this algorithm
+ */
+ public abstract Map<String, Map<String, Object>> getStats();
+
+ /**
+ * Returns a timestamp transformation algorithm
+ *
+ * @param trace
+ * The trace to get the transform for
+ * @return The timestamp transformation formula
+ */
+ public abstract ITmfTimestampTransform getTimestampTransform(ITmfTrace trace);
+
+ /**
+ * Returns a timestamp transformation algorithm
+ *
+ * @param name
+ * The name of the trace to get the transform for
+ * @return The timestamp transformation formula
+ */
+ public abstract ITmfTimestampTransform getTimestampTransform(String name);
+
+ /**
+ * Gets the quality of the synchronization between two given traces
+ *
+ * @param trace1
+ * First trace
+ * @param trace2
+ * Second trace
+ * @return The synchronization quality
+ */
+ public abstract SyncQuality getSynchronizationQuality(ITmfTrace trace1, ITmfTrace trace2);
+
+ /**
+ * Returns whether a given trace has a synchronization formula that is not
+ * identity. This function returns true if the synchronization algorithm has
+ * failed for some reason
+ *
+ * @param name
+ * The name of the trace
+ * @return true if trace has formula
+ */
+ public abstract boolean isTraceSynced(String name);
+
+ /**
+ * Rename a trace involved in this algorithm. This function is necessary
+ * because after synchronization, the trace whose timestamp changes is
+ * copied with a new name and the synchronization needs to keep track of the
+ * new name.
+ *
+ * @param oldname
+ * Original name of the trace
+ * @param newname
+ * New name of the trace
+ */
+ public abstract void renameTrace(String oldname, String newname);
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.synchronization;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+
+import org.eclipse.linuxtools.internal.tmf.core.Activator;
+
+/**
+ * Class to fetch and save synchronization information between traces
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public class SynchronizationBackend {
+
+ private static final int SYNC_FILE_MAGIC_NUMBER = 0x0DECAF00;
+
+ private static final int FILE_VERSION = 1;
+
+ private static final int HEADER_SIZE = 20;
+
+ private final File fSyncFile;
+
+ /**
+ * Constructor
+ *
+ * @param syncFile
+ * The file containing synchronization information
+ * @throws IOException
+ * If the file couldn't be opened for some reason
+ */
+ public SynchronizationBackend(File syncFile) throws IOException {
+ this(syncFile, true);
+ }
+
+ /**
+ * Constructor with possibility to tell whether to throw errors on exception
+ * or not
+ *
+ * @param syncFile
+ * The file containing synchronization information
+ * @param throwErrors
+ * Whether to throw exceptions or not
+ * @throws IOException
+ * If the file couldn't be opened for some reason
+ */
+ public SynchronizationBackend(File syncFile, boolean throwErrors) throws IOException {
+ /*
+ * Open the file ourselves, get the header information we need, then
+ * pass on the descriptor.
+ */
+ int res;
+
+ fSyncFile = syncFile;
+
+ if (syncFile == null) {
+ return;
+ }
+
+ if (!syncFile.exists()) {
+ if (throwErrors) {
+ throw new IOException("Selected synchronization file does not exist"); //$NON-NLS-1$
+ }
+ return;
+ }
+ if (syncFile.length() <= 0) {
+ if (throwErrors) {
+ throw new IOException("Invalid synchronization file selected, " + //$NON-NLS-1$
+ "target file is empty"); //$NON-NLS-1$
+ }
+ return;
+ }
+
+ FileInputStream fis = new FileInputStream(syncFile);
+ ByteBuffer buffer = ByteBuffer.allocate(HEADER_SIZE);
+ FileChannel fc = fis.getChannel();
+ buffer.clear();
+ fc.read(buffer);
+ buffer.flip();
+
+ /*
+ * Check the magic number,to make sure we're opening the right type of
+ * file
+ */
+ res = buffer.getInt();
+ if (res != SYNC_FILE_MAGIC_NUMBER) {
+ fc.close();
+ fis.close();
+ throw new IOException("Selected file does not" + //$NON-NLS-1$
+ "look like a synchronization file"); //$NON-NLS-1$
+ }
+
+ res = buffer.getInt(); /* Major version number */
+ if (res != FILE_VERSION) {
+ fc.close();
+ fis.close();
+ throw new IOException("Select synchronization file is of an older " //$NON-NLS-1$
+ + "format. Synchronization will have to be computed again."); //$NON-NLS-1$
+ }
+
+ res = buffer.getInt(); /* Minor version number */
+
+ fc.close();
+ fis.close();
+ }
+
+ /**
+ * Opens an existing synchronization file
+ *
+ * @return The synchronization algorithm contained in the file
+ * @throws IOException
+ * Exception returned file functions
+ */
+ public SynchronizationAlgorithm openExistingSync() throws IOException {
+
+ if (fSyncFile == null) {
+ return null;
+ }
+
+ /* Set the position after the header */
+ FileInputStream fis = new FileInputStream(fSyncFile);
+ FileChannel fc = fis.getChannel().position(HEADER_SIZE);
+
+ /* Read the input stream */
+ ObjectInputStream ois = new ObjectInputStream(fis);
+ SyncAlgorithmFullyIncremental syncAlgo = null;
+ try {
+ syncAlgo = (SyncAlgorithmFullyIncremental) ois.readObject();
+ } catch (ClassNotFoundException e) {
+
+ }
+ ois.close();
+ fc.close();
+
+ fis.close();
+
+ return syncAlgo;
+ }
+
+ /**
+ * Saves the synchronization algorithm object to file
+ *
+ * @param syncAlgo
+ * The algorithm to save
+ * @throws FileNotFoundException
+ * propagate callee's exceptions
+ */
+ public void saveSync(SynchronizationAlgorithm syncAlgo) throws FileNotFoundException {
+
+ if (fSyncFile == null) {
+ return;
+ }
+
+ FileChannel fc;
+ FileOutputStream fos;
+ ObjectOutputStream oos;
+ ByteBuffer buffer;
+ int res;
+
+ fos = new FileOutputStream(fSyncFile, false);
+ fc = fos.getChannel();
+
+ buffer = ByteBuffer.allocate(HEADER_SIZE);
+ buffer.clear();
+
+ /* Save the header of the file */
+ try {
+ fc.position(0);
+
+ buffer.putInt(SYNC_FILE_MAGIC_NUMBER);
+
+ buffer.putInt(FILE_VERSION);
+
+ buffer.flip();
+ res = fc.write(buffer);
+ assert (res <= HEADER_SIZE);
+ /* done writing the file header */
+
+ fc.position(HEADER_SIZE);
+
+ oos = new ObjectOutputStream(fos);
+ oos.writeObject(syncAlgo);
+ oos.close();
+
+ } catch (IOException e) {
+ /* We should not have any problems at this point... */
+ Activator.logError("Error saving trace synchronization data", e); //$NON-NLS-1$
+ } finally {
+ try {
+ fc.close();
+ fos.close();
+ } catch (IOException e) {
+ Activator.logError("Error closing synchronization file", e); //$NON-NLS-1$
+ }
+ }
+ return;
+
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.synchronization;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.linuxtools.internal.tmf.core.Activator;
+import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
+import org.eclipse.linuxtools.tmf.core.event.matching.ITmfEventMatching;
+import org.eclipse.linuxtools.tmf.core.event.matching.TmfNetworkEventMatching;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * This abstract manager class handles loading trace synchronization data or
+ * otherwise their calculation.
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public abstract class SynchronizationManager extends TmfComponent {
+
+ /**
+ * Function called to synchronize traces using the fully incremental
+ * synchronization algorithm
+ *
+ * @param syncFile
+ * The target name of the synchronization file. If it exists, it
+ * will be opened, otherwise it will be created and data from
+ * this synchro run will be saved there
+ * @param traces
+ * The list of traces to synchronize
+ * @param doSync
+ * Whether to actually synchronize or just try opening a sync
+ * file
+ * @return The synchronization object
+ */
+ public static SynchronizationAlgorithm synchronizeTraces(final File syncFile, final ITmfTrace[] traces, boolean doSync) {
+
+ SynchronizationAlgorithm syncAlgo;
+ if (doSync) {
+ syncAlgo = synchronize(syncFile, traces, new SyncAlgorithmFullyIncremental());
+ } else {
+ syncAlgo = openExisting(syncFile);
+ if (syncAlgo == null) {
+ syncAlgo = new SyncAlgorithmFullyIncremental();
+ }
+ }
+ return syncAlgo;
+ }
+
+ /**
+ * Function called to synchronize traces with a specific synchronization
+ * algorithm. If a synchronization already exists, but is not the requested
+ * algorithm, the synchronization is done again using the new algorithm
+ *
+ * @param syncFile
+ * The target name of the synchronization file. If it exists, it
+ * will be opened, otherwise it will be created and data from
+ * this synchro run will be saved there
+ * @param traces
+ * The list of traces to synchronize
+ * @param algo
+ * A synchronization algorithm object to determine the algorithm
+ * used to synchronization.
+ * @param doSync
+ * Whether to actually synchronize or just try opening a sync
+ * file
+ * @return The synchronization object
+ */
+ public static SynchronizationAlgorithm synchronizeTraces(final File syncFile, final ITmfTrace[] traces, SynchronizationAlgorithm algo, boolean doSync) {
+
+ SynchronizationAlgorithm syncAlgo;
+ if (doSync) {
+ syncAlgo = synchronize(syncFile, traces, algo);
+ } else {
+ syncAlgo = openExisting(syncFile);
+ if (syncAlgo == null || (syncAlgo.getClass() != algo.getClass())) {
+ if (algo != null) {
+ syncAlgo = algo;
+ } else {
+ syncAlgo = new SyncAlgorithmFullyIncremental();
+ }
+ }
+ }
+
+ return syncAlgo;
+ }
+
+ private static SynchronizationAlgorithm openExisting(final File syncFile) {
+ if ((syncFile != null) && syncFile.exists()) {
+ /* Load an existing history */
+ try {
+ SynchronizationBackend syncBackend = new SynchronizationBackend(syncFile);
+ SynchronizationAlgorithm algo = syncBackend.openExistingSync();
+ return algo;
+ } catch (IOException e) {
+ /*
+ * There was an error opening the existing file. Perhaps it was
+ * corrupted, perhaps it's an old version? We'll just
+ * fall-through and try to build a new one from scratch instead.
+ */
+ Activator.logInfo("Problem opening existing trace synchronization file", e); //$NON-NLS-1$
+ }
+ }
+ return null;
+ }
+
+ private static SynchronizationAlgorithm synchronize(final File syncFile, final ITmfTrace[] traces, SynchronizationAlgorithm syncAlgo) {
+ ITmfEventMatching matching = new TmfNetworkEventMatching(traces, syncAlgo);
+ matching.matchEvents();
+
+ SynchronizationBackend syncBackend;
+ try {
+ syncBackend = new SynchronizationBackend(syncFile, false);
+ syncBackend.saveSync(syncAlgo);
+ } catch (IOException e) {
+ Activator.logError("Error while saving trace synchronization file", e); //$NON-NLS-1$
+ }
+ return syncAlgo;
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.synchronization;
+
+import java.io.Serializable;
+
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+
+/**
+ * A default simple, identity timestamp transform. It is a singleton class and
+ * returns the timestamp itself
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public class TmfTimestampTransform implements ITmfTimestampTransform, Serializable {
+
+ /**
+ * Generated serial UID
+ */
+ private static final long serialVersionUID = -1480581417493073304L;
+
+ /**
+ * The unique instance of this transform, since it is always the same
+ */
+ public static final TmfTimestampTransform IDENTITY = new TmfTimestampTransform();
+
+ /**
+ * Default constructor
+ */
+ protected TmfTimestampTransform() {
+
+ }
+
+ @Override
+ public ITmfTimestamp transform(ITmfTimestamp timestamp) {
+ return timestamp;
+ }
+
+ @Override
+ public long transform(long timestamp) {
+ return timestamp;
+ }
+
+ @Override
+ public ITmfTimestampTransform composeWith(ITmfTimestampTransform composeWith) {
+ /* Since this transform will not modify anything, return the other */
+ return composeWith;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ return other.getClass().equals(TmfTimestampTransform.class);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = (prime * result) + TmfTimestampTransform.class.hashCode();
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "TmfTimestampTransform [ IDENTITY ]"; //$NON-NLS-1$
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.synchronization;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.MathContext;
+
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+
+/**
+ * Class implementing a linear timestamp transform, with a slope and/or offset
+ *
+ * f(t) = alpha*t + beta
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public class TmfTimestampTransformLinear implements ITmfTimestampTransform, Serializable {
+
+ /**
+ * Generated serial UID
+ */
+ private static final long serialVersionUID = -4756608071358979461L;
+
+ /**
+ * Respectively the slope and offset and this linear equation.
+ *
+ * FIXME: Maybe doubles will be enough, for the whole synchronization
+ * package as well, I think BigDecimal is a remnant of past trials and
+ * errors
+ */
+ private final BigDecimal fAlpha;
+ private final BigDecimal fBeta;
+
+ private static final MathContext fMc = MathContext.DECIMAL128;
+
+ /**
+ * Default constructor
+ */
+ public TmfTimestampTransformLinear() {
+ fAlpha = BigDecimal.ONE;
+ fBeta = BigDecimal.ZERO;
+ }
+
+ /**
+ * Constructor with alpha and beta
+ *
+ * @param alpha
+ * The slope of the linear transform
+ * @param beta
+ * The initial offset of the linear transform
+ */
+ public TmfTimestampTransformLinear(final double alpha, final double beta) {
+ fAlpha = BigDecimal.valueOf(alpha);
+ fBeta = BigDecimal.valueOf(beta);
+ }
+
+ /**
+ * Constructor with alpha and beta in big decimal
+ *
+ * @param fAlpha2
+ * The slope of the linear transform
+ * @param fBeta2
+ * The initial offset of the linear transform
+ */
+ public TmfTimestampTransformLinear(final BigDecimal fAlpha2, final BigDecimal fBeta2) {
+ if (fAlpha2 != null) {
+ fAlpha = fAlpha2;
+ } else {
+ fAlpha = BigDecimal.ONE;
+ }
+ if (fBeta2 != null) {
+ fBeta = fBeta2;
+ } else {
+ fBeta = BigDecimal.ZERO;
+ }
+ }
+
+ @Override
+ public ITmfTimestamp transform(ITmfTimestamp timestamp) {
+ BigDecimal newvalue = BigDecimal.valueOf(timestamp.getValue()).multiply(fAlpha, fMc).add(fBeta);
+ return new TmfTimestamp(timestamp, newvalue.longValue());
+ }
+
+ @Override
+ public long transform(long timestamp) {
+ BigDecimal t = BigDecimal.valueOf(timestamp).multiply(fAlpha, fMc).add(fBeta);
+ return t.longValue();
+ }
+
+ @Override
+ public ITmfTimestampTransform composeWith(ITmfTimestampTransform composeWith) {
+ if (composeWith.equals(TmfTimestampTransform.IDENTITY)) {
+ /* If composing with identity, just return this */
+ return this;
+ } else if (composeWith instanceof TmfTimestampTransformLinear) {
+ /* If composeWith is a linear transform, add the two together */
+ TmfTimestampTransformLinear ttl = (TmfTimestampTransformLinear) composeWith;
+ BigDecimal newAlpha = fAlpha.multiply(ttl.fAlpha, fMc);
+ BigDecimal newBeta = fAlpha.multiply(ttl.fBeta, fMc).add(fBeta);
+ return new TmfTimestampTransformLinear(newAlpha, newBeta);
+ } else {
+ /*
+ * We do not know what to do with this kind of transform, just
+ * return this
+ */
+ return this;
+ }
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ boolean result = false;
+ if (other instanceof TmfTimestampTransformLinear) {
+ TmfTimestampTransformLinear that = (TmfTimestampTransformLinear) other;
+ result = ((that.fAlpha.equals(fAlpha)) && (that.fBeta.equals(fBeta)));
+ }
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = (prime * result) + (fBeta.multiply(fAlpha).intValue());
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "TmfTimestampLinear [ alpha = " + fAlpha.toString() + //$NON-NLS-1$
+ ", beta = " + fBeta.toString() + //$NON-NLS-1$
+ " ]"; //$NON-NLS-1$
+ }
+
+}
--- /dev/null
+SyncAlgorithmFullyIncremental_absent=Absent
+SyncAlgorithmFullyIncremental_alpha=Alpha
+SyncAlgorithmFullyIncremental_beta=Beta
+SyncAlgorithmFullyIncremental_T_=T_
+SyncAlgorithmFullyIncremental_otherformula=C_T1(t)
+SyncAlgorithmFullyIncremental_mult=*
+SyncAlgorithmFullyIncremental_add=\ +
+SyncAlgorithmFullyIncremental_ub=Number of points in upper hull
+SyncAlgorithmFullyIncremental_lb=Number of points in lower hull
+SyncAlgorithmFullyIncremental_accuracy=Accuracy
+SyncAlgorithmFullyIncremental_accurate=Accurate
+SyncAlgorithmFullyIncremental_approx=Approximate
+SyncAlgorithmFullyIncremental_fail=Fail
+SyncAlgorithmFullyIncremental_incomplete=Incomplete
+SyncAlgorithmFullyIncremental_nbmatch=Number of matching packets received
+SyncAlgorithmFullyIncremental_nbacc=Number of accurate packets
+SyncAlgorithmFullyIncremental_reftrace=T0
+SyncAlgorithmFullyIncremental_othertrace=T1
+SyncAlgorithmFullyIncremental_refformula=C_T0(t)
+SyncAlgorithmFullyIncremental_NA=N/A
+SyncAlgorithmFullyIncremental_quality=Quality
\ No newline at end of file
/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
+ * Copyright (c) 2009, 2013 Ericsson, École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* Thomas Gatterweh - Updated scaling / synchronization
* Francois Chouinard - Refactoring to align with TMF Event Model 1.0
* Francois Chouinard - Implement augmented interface
+ * Geneviève Bastien - Added copy constructor with new value
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.timestamp;
fPrecision = timestamp.getPrecision();
}
+ /**
+ * Copies a timestamp but with a new time value
+ *
+ * @param timestamp
+ * The timestamp to copy
+ * @param newvalue
+ * The value the new timestamp will have
+ * @since 3.0
+ */
+ public TmfTimestamp(ITmfTimestamp timestamp, long newvalue) {
+ if (timestamp == null) {
+ throw new IllegalArgumentException();
+ }
+ fValue = newvalue;
+ fScale = timestamp.getScale();
+ fPrecision = timestamp.getPrecision();
+ }
+
// ------------------------------------------------------------------------
// ITmfTimestamp
// ------------------------------------------------------------------------
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Patrick Tasse - Updated for location in checkpoint
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-
-/**
- * The basic trace checkpoint structure in TMF. The purpose of the checkpoint is
- * to associate a trace location to an event timestamp.
- *
- * @version 1.0
- * @author Francois Chouinard
- *
- * @see ITmfTimestamp
- * @see ITmfLocation
- */
-public interface ITmfCheckpoint extends Comparable<ITmfCheckpoint> {
-
- // ------------------------------------------------------------------------
- // Getters
- // ------------------------------------------------------------------------
-
- /**
- * @return the timestamp of the event referred to by the context
- * @since 2.0
- */
- ITmfTimestamp getTimestamp();
-
- /**
- * @return the location of the event referred to by the checkpoint
- */
- ITmfLocation getLocation();
-
- // ------------------------------------------------------------------------
- // Comparable
- // ------------------------------------------------------------------------
-
- @Override
- int compareTo(ITmfCheckpoint checkpoint);
-
-}
package org.eclipse.linuxtools.tmf.core.trace;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+
/**
* The basic trace context structure in TMF. The purpose of the context is to
* associate a trace location to an event at a specific rank (order).
/**
* @return the location of the event at the context rank
+ * @since 3.0
*/
ITmfLocation getLocation();
/**
* @param location the new location
+ * @since 3.0
*/
void setLocation(ITmfLocation location);
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Francois Chouinard - Updated as per TMF Trace Model 1.0
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-/**
- * The generic trace location in TMF.
- * <p>
- * An ITmfLocation is the equivalent of a random-access file position, holding
- * enough information to allow the positioning of the trace 'pointer' to read an
- * arbitrary event.
- * <p>
- * This location is trace-specific, must be comparable and immutable.
- *
- * @version 2.0
- * @author Francois Chouinard
- */
-public interface ITmfLocation {
-
- // ------------------------------------------------------------------------
- // Getters
- // ------------------------------------------------------------------------
-
- /**
- * Returns the concrete trace location information
- *
- * @return the location information
- * @since 2.0
- */
- Comparable<?> getLocationInfo();
-
-}
/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
+ * Copyright (c) 2009, 2013 Ericsson, École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* Contributors:
* Francois Chouinard - Initial API and implementation
* Francois Chouinard - Updated as per TMF Trace Model 1.0
+ * Geneviève Bastien - Added timestamp transforms and timestamp
+ * creation functions
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.trace;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
import org.eclipse.linuxtools.tmf.core.statistics.ITmfStatistics;
+import org.eclipse.linuxtools.tmf.core.synchronization.ITmfTimestampTransform;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* The event stream structure in TMF. In its basic form, a trace has:
* <li> the time range (span) of the events it contains
* </ul>
* Concrete ITmfTrace classes have to provide a parameter-less constructor and
- * an initialization method (<i>initTrace</i>) if they are to be opened from
- * the Project View. Also, a validation method (<i>validate</i>) has to be
- * provided to ensure that the trace is of the correct type.
+ * an initialization method (<i>initTrace</i>) if they are to be opened from the
+ * Project View. Also, a validation method (<i>validate</i>) has to be provided
+ * to ensure that the trace is of the correct type.
* <p>
* A trace can be accessed simultaneously from multiple threads by various
* application components. To avoid obvious multi-threading issues, the trace
* event = trace.getNext(context);
* }
* </pre>
+ *
* A trace is also an event provider so it can process event requests
* asynchronously (and coalesce compatible, concurrent requests).
* <p>
- * </pre>
- * <b>Example 4</b>: Process a whole trace (see ITmfEventRequest for variants)
+ *
+ * <b>Example 4</b>: Process a whole trace (see ITmfEventRequest for
+ * variants)
* <pre>
* ITmfRequest request = new TmfEventRequest<MyEventType>(MyEventType.class) {
- * @Override
+ * @Override
* public void handleData(MyEventType event) {
* super.handleData(event);
* processEvent(event);
* }
- * @Override
+ *
+ * @Override
* public void handleCompleted() {
* finish();
* super.handleCompleted();
* properly parameterize an ITmfTrace instantiated with its parameterless
* constructor.
* <p>
- * Typically, the parameterless constructor will provide the block size
- * and its associated parser and indexer.
+ * Typically, the parameterless constructor will provide the block size and
+ * its associated parser and indexer.
*
- * @param resource the trace resource
- * @param path the trace path
- * @param type the trace event type
- * @throws TmfTraceException If we couldn't open the trace
+ * @param resource
+ * the trace resource
+ * @param path
+ * the trace path
+ * @param type
+ * the trace event type
+ * @throws TmfTraceException
+ * If we couldn't open the trace
*/
void initTrace(IResource resource, String path, Class<? extends ITmfEvent> type) throws TmfTraceException;
/**
* Validate that the trace is of the correct type.
*
- * @param project the eclipse project
- * @param path the trace path
- *
- * @return an IStatus object with validation result. Use severity OK to indicate success.
+ * @param project
+ * the eclipse project
+ * @param path
+ * the trace path
+ * @return an IStatus object with validation result. Use severity OK to
+ * indicate success.
* @since 2.0
*/
IStatus validate(IProject project, String path);
/**
* @return the current trace location
+ * @since 3.0
*/
ITmfLocation getCurrentLocation();
/**
* Returns the ratio (proportion) corresponding to the specified location.
*
- * @param location a trace specific location
+ * @param location
+ * a trace specific location
* @return a floating-point number between 0.0 (beginning) and 1.0 (end)
+ * @since 3.0
*/
double getLocationRatio(ITmfLocation location);
* If not null, the location requested must be valid otherwise the returned
* context is undefined (up to the implementation to recover if possible).
* <p>
- * @param location the trace specific location
+ *
+ * @param location
+ * the trace specific location
* @return a context which can later be used to read the corresponding event
+ * @since 3.0
*/
ITmfContext seekEvent(ITmfLocation location);
/**
* Position the trace at the 'rank'th event in the trace.
* <p>
- * A rank <= 0 is interpreted as seeking for the first event of the
- * trace.
+ * A rank <= 0 is interpreted as seeking for the first event of the trace.
* <p>
* If the requested rank is beyond the last trace event, the context
* returned will yield a null event if used in a subsequent read.
*
- * @param rank the event rank
+ * @param rank
+ * the event rank
* @return a context which can later be used to read the corresponding event
*/
ITmfContext seekEvent(long rank);
/**
* Position the trace at the first event with the specified timestamp. If
- * there is no event with the requested timestamp, a context pointing to
- * the next chronological event is returned.
+ * there is no event with the requested timestamp, a context pointing to the
+ * next chronological event is returned.
* <p>
* A null timestamp is interpreted as seeking for the first event of the
* trace.
* If the requested timestamp is beyond the last trace event, the context
* returned will yield a null event if used in a subsequent read.
*
- * @param timestamp the timestamp of desired event
+ * @param timestamp
+ * the timestamp of desired event
* @return a context which can later be used to read the corresponding event
* @since 2.0
*/
* voluntarily vague. Typically, it would refer to the event proportional
* rank (arguably more intuitive) or timestamp in the trace file.
*
- * @param ratio the proportional 'rank' in the trace
+ * @param ratio
+ * the proportional 'rank' in the trace
* @return a context which can later be used to read the corresponding event
*/
ITmfContext seekEvent(double ratio);
* @since 2.0
*/
ITmfTimestamp getInitialRangeOffset();
+
+ /**
+ * Returns the ID of the host this trace is from. The host ID is not
+ * necessarily the hostname, but should be a unique identifier for the
+ * machine on which the trace was taken. It can be used to determine if two
+ * traces were taken on the exact same machine (timestamp are already
+ * synchronized, resources with same id are the same if taken at the same
+ * time, etc).
+ *
+ * @return The host id of this trace
+ * @since 3.0
+ */
+ String getHostId();
+
+ // ------------------------------------------------------------------------
+ // Timestamp transformation functions
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns the timestamp transformation for this trace
+ *
+ * @return the timestamp transform
+ * @since 3.0
+ */
+ ITmfTimestampTransform getTimestampTransform();
+
+ /**
+ * Sets the trace's timestamp transform
+ *
+ * @param tt
+ * The timestamp transform for all timestamps of this trace
+ * @since 3.0
+ */
+ void setTimestampTransform(final ITmfTimestampTransform tt);
+
+ /**
+ * Creates a timestamp for this trace, using the transformation formula
+ *
+ * @param ts
+ * The time in long with which to create the timestamp
+ * @return The new timestamp
+ * @since 3.0
+ */
+ ITmfTimestamp createTimestamp(long ts);
+
}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-
-/**
- * The generic trace indexer in TMF with support for incremental indexing.
- *
- * @version 1.0
- * @author Francois Chouinard
- *
- * @see ITmfTrace
- * @see ITmfEvent
- */
-public interface ITmfTraceIndexer {
-
- /**
- * Start an asynchronous index building job and waits for the job completion
- * if required. Typically, the indexing job sends notifications at regular
- * intervals to indicate its progress.
- * <p>
- * <b>Example 1</b>: Index a whole trace asynchronously
- *
- * <pre>
- * trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, false);
- * </pre>
- *
- * <b>Example 2</b>: Index a whole trace synchronously
- *
- * <pre>
- * trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
- * </pre>
- *
- * <b>Example 3</b>: Index a trace asynchronously, starting at rank 100
- *
- * <pre>
- * trace.getIndexer().buildIndex(100, TmfTimeRange.ETERNITY, false);
- * </pre>
- *
- * <b>Example 4</b>: Index a trace asynchronously, starting at rank 100 for
- * events between T1 and T2 (inclusive). This is used for incremental
- * indexing.
- *
- * <pre>
- * TmfTimeRange range = new TmfTimeRange(T1, T2);
- * trace.getIndexer().buildIndex(100, range, false);
- * </pre>
- *
- * @param offset
- * The offset of the first event to consider
- * @param range
- * The time range to consider
- * @param waitForCompletion
- * Should we block the calling thread until the build is
- * complete?
- * @since 2.0
- */
- void buildIndex(long offset, TmfTimeRange range, boolean waitForCompletion);
-
- /**
- * Indicates that the indexer is busy indexing the trace.
- * Will always return false if the indexing is done synchronously.
- *
- * @return the state of the indexer (indexing or not)
- */
- boolean isIndexing();
-
- /**
- * Adds an entry to the trace index.
- *
- * @param context The trace context to save
- * @param timestamp The timestamp matching this context
- * @since 2.0
- */
- void updateIndex(ITmfContext context, ITmfTimestamp timestamp);
-
- /**
- * Returns the context of the checkpoint immediately preceding the requested
- * timestamp (or at the timestamp if it coincides with a checkpoint).
- *
- * @param timestamp the requested timestamp
- * @return the checkpoint context
- * @since 2.0
- */
- ITmfContext seekIndex(ITmfTimestamp timestamp);
-
- /**
- * Returns the context of the checkpoint immediately preceding the requested
- * rank (or at rank if it coincides with a checkpoint).
- *
- * @param rank the requested event rank
- * @return the checkpoint context
- */
- ITmfContext seekIndex(long rank);
-
- /**
- * Perform cleanup when the indexer is no longer required.
- */
- void dispose();
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Francois Chouinard - Updated as per TMF Trace Model 1.0
- * Patrick Tasse - Updated for location in checkpoint
- ******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-
-/**
- * A basic implementation of ITmfCheckpoint. It simply maps an event timestamp
- * to a generic location.
- *
- * @version 1.0
- * @author Francois Chouinard
- *
- * @see ITmfLocation
- * @see ITmfTimestamp
- */
-public class TmfCheckpoint implements ITmfCheckpoint {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- // The checkpoint location
- private final ITmfLocation fLocation;
-
- // The checkpoint timestamp
- private final ITmfTimestamp fTimestamp;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Full constructor
- *
- * @param timestamp the checkpoint timestamp
- * @param location the corresponding trace location
- * @since 2.0
- */
- public TmfCheckpoint(final ITmfTimestamp timestamp, final ITmfLocation location) {
- fTimestamp = timestamp;
- fLocation = location;
- }
-
- /**
- * Copy constructor
- *
- * @param other the other checkpoint
- */
- public TmfCheckpoint(final TmfCheckpoint other) {
- if (other == null) {
- throw new IllegalArgumentException();
- }
- fTimestamp = other.fTimestamp;
- fLocation = other.fLocation;
- }
-
- // ------------------------------------------------------------------------
- // ITmfCheckpoint
- // ------------------------------------------------------------------------
-
- /**
- * @since 2.0
- */
- @Override
- public ITmfTimestamp getTimestamp() {
- return fTimestamp;
- }
-
- @Override
- public ITmfLocation getLocation() {
- return fLocation;
- }
-
- // ------------------------------------------------------------------------
- // Comparable
- // ------------------------------------------------------------------------
-
- @Override
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public int compareTo(final ITmfCheckpoint other) {
- int comp = 0;
- if ((fTimestamp != null) && (other.getTimestamp() != null)) {
- comp = fTimestamp.compareTo(other.getTimestamp(), false);
- if (comp != 0) {
- return comp;
- }
- // compare locations if timestamps are the same
- }
-
- if ((fLocation == null) && (other.getLocation() == null)) {
- return 0;
- }
-
- // treat location of other as null location which is before any location
- if ((fLocation != null) && (other.getLocation() == null)) {
- return 1;
- }
-
- // treat this as null location which is before any other locations
- if ((fLocation == null) && (other.getLocation() != null)) {
- return -1;
- }
-
- // compare location
- final Comparable location1 = getLocation().getLocationInfo();
- final Comparable location2 = other.getLocation().getLocationInfo();
- return location1.compareTo(location2);
- }
-
- // ------------------------------------------------------------------------
- // Object
- // ------------------------------------------------------------------------
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((fLocation == null) ? 0 : fLocation.hashCode());
- result = prime * result + ((fTimestamp == null) ? 0 : fTimestamp.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof TmfCheckpoint)) {
- return false;
- }
- final TmfCheckpoint other = (TmfCheckpoint) obj;
- if (fLocation == null) {
- if (other.fLocation != null) {
- return false;
- }
- } else if (!fLocation.equals(other.fLocation)) {
- return false;
- }
- if (fTimestamp == null) {
- if (other.fTimestamp != null) {
- return false;
- }
- } else if (!fTimestamp.equals(other.fTimestamp)) {
- return false;
- }
- return true;
- }
-
- @Override
- @SuppressWarnings("nls")
- public String toString() {
- return getClass().getSimpleName() + " [fLocation=" + fLocation + ", fTimestamp=" + fTimestamp + "]";
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.linuxtools.internal.tmf.core.Messages;
-import org.eclipse.linuxtools.tmf.core.component.TmfDataProvider;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-
-/**
- * A simple indexer that manages the trace index as an array of trace
- * checkpoints. Checkpoints are stored at fixed intervals (event rank) in
- * ascending timestamp order.
- * <p>
- * The goal being to access a random trace event reasonably fast from the user's
- * standpoint, picking the right interval value becomes a trade-off between speed
- * and memory usage (a shorter inter-event interval is faster but requires more
- * checkpoints).
- * <p>
- * Locating a specific checkpoint is trivial for both rank (rank % interval) and
- * timestamp (bsearch in the array).
- *
- * @version 1.0
- * @author Francois Chouinard
- *
- * @see ITmfTrace
- * @see ITmfEvent
- */
-public class TmfCheckpointIndexer implements ITmfTraceIndexer {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- /** The event trace to index */
- protected final ITmfTrace fTrace;
-
- /** The interval between checkpoints */
- private final int fCheckpointInterval;
-
- /** The event trace to index */
- private boolean fIsIndexing;
-
- /**
- * The trace index. It is composed of checkpoints taken at intervals of
- * fCheckpointInterval events.
- */
- protected final List<ITmfCheckpoint> fTraceIndex;
-
- /**
- * The indexing request
- */
- private ITmfEventRequest fIndexingRequest = null;
-
- // ------------------------------------------------------------------------
- // Construction
- // ------------------------------------------------------------------------
-
- /**
- * Basic constructor that uses the default trace block size as checkpoints
- * intervals
- *
- * @param trace the trace to index
- */
- public TmfCheckpointIndexer(final ITmfTrace trace) {
- this(trace, TmfDataProvider.DEFAULT_BLOCK_SIZE);
- }
-
- /**
- * Full trace indexer
- *
- * @param trace the trace to index
- * @param interval the checkpoints interval
- */
- public TmfCheckpointIndexer(final ITmfTrace trace, final int interval) {
- fTrace = trace;
- fCheckpointInterval = interval;
- fTraceIndex = new ArrayList<ITmfCheckpoint>();
- fIsIndexing = false;
- }
-
- @Override
- public void dispose() {
- if ((fIndexingRequest != null) && !fIndexingRequest.isCompleted()) {
- fIndexingRequest.cancel();
- fTraceIndex.clear();
- }
- }
-
- // ------------------------------------------------------------------------
- // ITmfTraceIndexer - isIndexing
- // ------------------------------------------------------------------------
-
- @Override
- public boolean isIndexing() {
- return fIsIndexing;
- }
-
- // ------------------------------------------------------------------------
- // ITmfTraceIndexer - buildIndex
- // ------------------------------------------------------------------------
-
- /**
- * @since 2.0
- */
- @Override
- public void buildIndex(final long offset, final TmfTimeRange range, final boolean waitForCompletion) {
-
- // Don't do anything if we are already indexing
- synchronized (fTraceIndex) {
- if (fIsIndexing) {
- return;
- }
- fIsIndexing = true;
- }
-
- // The monitoring job
- final Job job = new Job("Indexing " + fTrace.getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$
- @Override
- protected IStatus run(final IProgressMonitor monitor) {
- monitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
- while (!monitor.isCanceled()) {
- try {
- long prevNbEvents = fTrace.getNbEvents();
- Thread.sleep(250);
- long nbEvents = fTrace.getNbEvents();
- setName(Messages.TmfCheckpointIndexer_Indexing + ' ' + fTrace.getName() + " (" + nbEvents + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- // setName doesn't refresh the UI, setTaskName does
- long rate = (nbEvents - prevNbEvents) * 4;
- monitor.setTaskName(rate + " " + Messages.TmfCheckpointIndexer_EventsPerSecond); //$NON-NLS-1$
- } catch (final InterruptedException e) {
- return Status.OK_STATUS;
- }
- }
- monitor.done();
- return Status.OK_STATUS;
- }
- };
- job.schedule();
-
- // Build a background request for all the trace data. The index is
- // updated as we go by readNextEvent().
- fIndexingRequest = new TmfEventRequest(ITmfEvent.class,
- range, offset, TmfDataRequest.ALL_DATA, fCheckpointInterval, ITmfDataRequest.ExecutionType.BACKGROUND)
- {
- @Override
- public void handleData(final ITmfEvent event) {
- super.handleData(event);
- if (event != null) {
- // Update the trace status at regular intervals
- if ((getNbRead() % fCheckpointInterval) == 0) {
- updateTraceStatus();
- }
- }
- }
-
- @Override
- public void handleSuccess() {
- updateTraceStatus();
- }
-
- @Override
- public void handleCompleted() {
- job.cancel();
- super.handleCompleted();
- fIsIndexing = false;
- }
-
- private void updateTraceStatus() {
- if (fTrace.getNbEvents() > 0) {
- signalNewTimeRange(fTrace.getStartTime(), fTrace.getEndTime());
- }
- }
- };
-
- // Submit the request and wait for completion if required
- fTrace.sendRequest(fIndexingRequest);
- if (waitForCompletion) {
- try {
- fIndexingRequest.waitForCompletion();
- } catch (final InterruptedException e) {
- }
- }
- }
-
- /**
- * Notify the interested parties that the trace time range has changed
- *
- * @param startTime the new start time
- * @param endTime the new end time
- */
- private void signalNewTimeRange(final ITmfTimestamp startTime, final ITmfTimestamp endTime) {
- fTrace.broadcast(new TmfTraceUpdatedSignal(fTrace, fTrace, new TmfTimeRange(startTime, endTime)));
- }
-
- // ------------------------------------------------------------------------
- // ITmfTraceIndexer - updateIndex
- // ------------------------------------------------------------------------
-
- /**
- * @since 2.0
- */
- @Override
- public synchronized void updateIndex(final ITmfContext context, final ITmfTimestamp timestamp) {
- if ((context.getRank() % fCheckpointInterval) == 0) {
- // Determine the table position
- final long position = context.getRank() / fCheckpointInterval;
- // Add new entry at proper location (if empty)
- if (fTraceIndex.size() == position) {
- fTraceIndex.add(new TmfCheckpoint(timestamp, context.getLocation()));
- }
- }
- }
-
- // ------------------------------------------------------------------------
- // ITmfTraceIndexer - seekIndex
- // ------------------------------------------------------------------------
-
- /**
- * @since 2.0
- */
- @Override
- public synchronized ITmfContext seekIndex(final ITmfTimestamp timestamp) {
-
- // A null timestamp indicates to seek the first event
- if (timestamp == null) {
- return fTrace.seekEvent(0);
- }
-
- // Find the checkpoint at or before the requested timestamp.
- // In the very likely event that the timestamp is not at a checkpoint
- // boundary, bsearch will return index = (- (insertion point + 1)).
- // It is then trivial to compute the index of the previous checkpoint.
- int index = Collections.binarySearch(fTraceIndex, new TmfCheckpoint(timestamp, null));
- if (index < 0) {
- index = Math.max(0, -(index + 2));
- } else {
- // If timestamp was in the list, use previous index to be able to find the
- // first event with the same timestamp before the checkpoint
- index = Math.max(0, index - 1);
- }
-
- // Position the trace at the checkpoint
- return restoreCheckpoint(index);
- }
-
- @Override
- public ITmfContext seekIndex(final long rank) {
-
- // A rank < 0 indicates to seek the first event
- if (rank < 0) {
- return fTrace.seekEvent(0);
- }
-
- // Find the checkpoint at or before the requested rank.
- final int index = (int) rank / fCheckpointInterval;
-
- // Position the trace at the checkpoint
- return restoreCheckpoint(index);
- }
-
- /**
- * Position the trace at the given checkpoint
- *
- * @param checkpoint the checkpoint index
- * @return the corresponding context
- */
- private ITmfContext restoreCheckpoint(final int checkpoint) {
- ITmfLocation location = null;
- int index = 0;
- synchronized (fTraceIndex) {
- if (!fTraceIndex.isEmpty()) {
- index = checkpoint;
- if (index >= fTraceIndex.size()) {
- index = fTraceIndex.size() - 1;
- }
- location = fTraceIndex.get(index).getLocation();
- }
- }
- final ITmfContext context = fTrace.seekEvent(location);
- context.setRank((long) index * fCheckpointInterval);
- return context;
- }
-
- // ------------------------------------------------------------------------
- // Getters
- // ------------------------------------------------------------------------
-
- /**
- * @return the trace index
- */
- protected List<ITmfCheckpoint> getTraceIndex() {
- return fTraceIndex;
- }
-
-}
package org.eclipse.linuxtools.tmf.core.trace;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+
/**
* A basic implementation of ITmfContext.
* <p>
* Simple constructor (unknown rank)
*
* @param location the event location
+ * @since 3.0
*/
public TmfContext(final ITmfLocation location) {
this(location, UNKNOWN_RANK);
*
* @param location the event location
* @param rank the event rank
+ * @since 3.0
*/
public TmfContext(final ITmfLocation location, final long rank) {
fLocation = location;
// ITmfContext
// ------------------------------------------------------------------------
+ /**
+ * @since 3.0
+ */
@Override
public ITmfLocation getLocation() {
return fLocation;
}
+ /**
+ * @since 3.0
+ */
@Override
public void setLocation(final ITmfLocation location) {
fLocation = location;
/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
+ * Copyright (c) 2009, 2013 Ericsson, École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* Francois Chouinard - Updated as per TMF Trace Model 1.0
* Patrick Tasse - Updated for removal of context clone
* Patrick Tasse - Updated for ranks in experiment location
+ * Geneviève Bastien - Added support of experiment synchronization
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.trace;
+import java.io.File;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.internal.tmf.core.Activator;
import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentContext;
import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentLocation;
import org.eclipse.linuxtools.internal.tmf.core.trace.TmfLocationArray;
+import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceRangeUpdatedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSynchronizedSignal;
+import org.eclipse.linuxtools.tmf.core.synchronization.SynchronizationAlgorithm;
+import org.eclipse.linuxtools.tmf.core.synchronization.SynchronizationManager;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* TmfExperiment presents a time-ordered, unified view of a set of ITmfTrace:s
// Constants
// ------------------------------------------------------------------------
+ /**
+ * The file name of the Synchronization
+ *
+ * @since 3.0
+ */
+ public final static String SYNCHRONIZATION_FILE_NAME = "synchronization.bin"; //$NON-NLS-1$
+
/**
* The default index page size
*/
// ------------------------------------------------------------------------
/**
- * @param type the event type
- * @param id the experiment id
- * @param traces the experiment set of traces
+ * @param type
+ * the event type
+ * @param id
+ * the experiment id
+ * @param traces
+ * the experiment set of traces
*/
public TmfExperiment(final Class<? extends ITmfEvent> type, final String id, final ITmfTrace[] traces) {
this(type, id, traces, DEFAULT_INDEX_PAGE_SIZE, null);
this(type, id, traces, DEFAULT_INDEX_PAGE_SIZE, resource);
}
-
/**
- * @param type the event type
- * @param path the experiment path
- * @param traces the experiment set of traces
- * @param indexPageSize the experiment index page size
+ * @param type
+ * the event type
+ * @param path
+ * the experiment path
+ * @param traces
+ * the experiment set of traces
+ * @param indexPageSize
+ * the experiment index page size
*/
public TmfExperiment(final Class<? extends ITmfEvent> type, final String path, final ITmfTrace[] traces, final int indexPageSize) {
this(type, path, traces, indexPageSize, null);
}
fTraces = traces;
+
+ if (resource != null) {
+ try {
+ this.synchronizeTraces();
+ } catch (TmfTraceException e) {
+ Activator.logError("Error synchronizing experiment", e); //$NON-NLS-1$
+ }
+ }
}
/**
* Returns the timestamp of the event at the requested index. If none,
* returns null.
*
- * @param index the event index (rank)
+ * @param index
+ * the event index (rank)
* @return the corresponding event timestamp
* @since 2.0
*/
/**
* Set the file to be used for bookmarks on this experiment
*
- * @param file the bookmarks file
+ * @param file
+ * the bookmarks file
*/
public void setBookmarksFile(final IFile file) {
fBookmarksFile = file;
}
if (request instanceof ITmfEventRequest
- && !TmfTimestamp.BIG_BANG.equals(((ITmfEventRequest) request).getRange().getStartTime())
- && request.getIndex() == 0)
+ && !TmfTimestamp.BIG_BANG.equals(((ITmfEventRequest) request).getRange().getStartTime())
+ && request.getIndex() == 0)
{
final ITmfContext context = seekEvent(((ITmfEventRequest) request).getRange().getStartTime());
((ITmfEventRequest) request).setStartIndex((int) context.getRank());
// ITmfTrace trace positioning
// ------------------------------------------------------------------------
+ /**
+ * @since 3.0
+ */
@Override
public synchronized ITmfContext seekEvent(final ITmfLocation location) {
// Validate the location
return context;
}
+ /**
+ * @since 3.0
+ */
@Override
public double getLocationRatio(final ITmfLocation location) {
if (location instanceof TmfExperimentLocation) {
return 0.0;
}
+ /**
+ * @since 3.0
+ */
@Override
public ITmfLocation getCurrentLocation() {
// never used
TmfExperimentContext expContext = (TmfExperimentContext) context;
- // If an event was consumed previously, first get the next one from that trace
+ // If an event was consumed previously, first get the next one from that
+ // trace
final int lastTrace = expContext.getLastTrace();
if (lastTrace != TmfExperimentContext.NO_TRACE) {
final ITmfContext traceContext = expContext.getContexts()[lastTrace];
return initTs;
}
+ /**
+ * Synchronizes the traces of an experiment. By default it only tries to
+ * read a synchronization file if it exists
+ *
+ * @return The synchronization object
+ * @throws TmfTraceException
+ * propagate TmfTraceExceptions
+ * @since 3.0
+ */
+ public synchronized SynchronizationAlgorithm synchronizeTraces() throws TmfTraceException {
+ return synchronizeTraces(false);
+ }
+
+ /**
+ * Synchronizes the traces of an experiment.
+ *
+ * @param doSync
+ * Whether to actually synchronize or just try opening a sync
+ * file
+ * @return The synchronization object
+ * @throws TmfTraceException
+ * propagate TmfTraceExceptions
+ * @since 3.0
+ */
+ public synchronized SynchronizationAlgorithm synchronizeTraces(boolean doSync) throws TmfTraceException {
+
+ /* Set up the path to the synchronization file we'll use */
+ IResource resource = this.getResource();
+ String supplDirectory = null;
+
+ try {
+ /* get the directory where the file will be stored. */
+ if (resource != null) {
+ supplDirectory = resource.getPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER);
+ }
+ } catch (CoreException e) {
+ throw new TmfTraceException(e.toString(), e);
+ }
+
+ final File syncFile = (supplDirectory != null) ? new File(supplDirectory + File.separator + SYNCHRONIZATION_FILE_NAME) : null;
+
+ final SynchronizationAlgorithm syncAlgo = SynchronizationManager.synchronizeTraces(syncFile, fTraces, doSync);
+
+ final TmfTraceSynchronizedSignal signal = new TmfTraceSynchronizedSignal(this, syncAlgo);
+
+ /* Broadcast in separate thread to prevent deadlock */
+ new Thread() {
+ @Override
+ public void run() {
+ broadcast(signal);
+ }
+ }.start();
+
+ return syncAlgo;
+ }
+
@Override
@SuppressWarnings("nls")
public synchronized String toString() {
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Francois Chouinard - Updated as per TMF Trace Model 1.0
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-
-/**
- * A abstract implementation of ITmfLocation. The concrete classes must provide
- * comparable location information.
- *
- * @version 2.0
- * @author Francois Chouinard
- */
-public abstract class TmfLocation implements ITmfLocation {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final Comparable<?> fLocationInfo;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Standard constructor.
- *
- * @param locationInfo
- * The concrete trace location
- */
- public TmfLocation(final Comparable<?> locationInfo) {
- fLocationInfo = locationInfo;
- }
-
- /**
- * Copy constructor
- *
- * @param location
- * The original trace location
- */
- public TmfLocation(final TmfLocation location) {
- fLocationInfo = location.fLocationInfo;
- }
-
- // ------------------------------------------------------------------------
- // Getters
- // ------------------------------------------------------------------------
-
- /**
- * @since 2.0
- */
- @Override
- public Comparable<?> getLocationInfo() {
- return fLocationInfo;
- }
-
- // ------------------------------------------------------------------------
- // Object
- // ------------------------------------------------------------------------
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((fLocationInfo != null) ? fLocationInfo.hashCode() : 0);
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final TmfLocation other = (TmfLocation) obj;
- if (fLocationInfo == null) {
- if (other.fLocationInfo != null) {
- return false;
- }
- } else if (!fLocationInfo.equals(other.fLocationInfo)) {
- return false;
- }
- return true;
- }
-
- @Override
- @SuppressWarnings("nls")
- public String toString() {
- return getClass().getSimpleName() + " [fLocationInfo=" + fLocationInfo + "]";
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-/**
- * A concrete implementation of TmfLocation based on Long:s
- *
- * @author Francois Chouinard
- * @since 2.0
- */
-public final class TmfLongLocation extends TmfLocation {
-
- /**
- * The normal constructor
- *
- * @param locationInfo the concrete location
- */
- public TmfLongLocation(final Long locationInfo) {
- super(locationInfo);
- }
-
- /**
- * The copy constructor
- *
- * @param other the other location
- */
- public TmfLongLocation(final TmfLongLocation other) {
- super(other.getLocationInfo());
- }
-
- @Override
- public Long getLocationInfo() {
- return (Long) super.getLocationInfo();
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.trace;
-
-import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
-
-/**
- * A concrete implementation of TmfLocation based on ITmfTimestamp:s
- *
- * @author Francois Chouinard
- * @since 2.0
- */
-public final class TmfTimestampLocation extends TmfLocation {
-
- /**
- * The normal constructor
- *
- * @param locationInfo the concrete location
- */
- public TmfTimestampLocation(final ITmfTimestamp locationInfo) {
- super(locationInfo);
- }
-
- /**
- * The copy constructor
- *
- * @param other the other location
- */
- public TmfTimestampLocation(final TmfTimestampLocation other) {
- super(other.getLocationInfo());
- }
-
- @Override
- public ITmfTimestamp getLocationInfo() {
- return (ITmfTimestamp) super.getLocationInfo();
- }
-
-}
/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
+ * Copyright (c) 2009, 2013 Ericsson, École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* Francois Chouinard - Initial API and implementation
* Francois Chouinard - Updated as per TMF Trace Model 1.0
* Patrick Tasse - Updated for removal of context clone
+ * Geneviève Bastien - Added timestamp transforms, its saving to file and
+ * timestamp creation functions
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.trace;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.internal.tmf.core.Activator;
+import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
import org.eclipse.linuxtools.tmf.core.statistics.ITmfStatistics;
import org.eclipse.linuxtools.tmf.core.statistics.TmfStateStatistics;
+import org.eclipse.linuxtools.tmf.core.synchronization.ITmfTimestampTransform;
+import org.eclipse.linuxtools.tmf.core.synchronization.TmfTimestampTransform;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* Abstract implementation of ITmfTrace.
protected final Map<String, ITmfStateSystem> fStateSystems =
new LinkedHashMap<String, ITmfStateSystem>();
+ private ITmfTimestampTransform fTsTransform;
+
+ private static final String SYNCHRONIZATION_FORMULA_FILE = "sync_formula"; //$NON-NLS-1$
+
// ------------------------------------------------------------------------
// Construction
// ------------------------------------------------------------------------
* The default implementation of TmfTrace uses a TmfStatistics back-end.
* Override this if you want to specify another type (or none at all).
*
- * @throws TmfTraceException
- * If there was a problem setting up the statistics
- * @since 2.0
+ * @return An IStatus indicating if the statistics could be built
+ * successfully or not.
+ * @since 3.0
*/
- protected void buildStatistics() throws TmfTraceException {
+ protected IStatus buildStatistics() {
/*
* Initialize the statistics provider, but only if a Resource has been
* set (so we don't build it for experiments, for unit tests, etc.)
*/
- fStatistics = (fResource == null ? null : new TmfStateStatistics(this) );
+ try {
+ fStatistics = (fResource == null ? null : new TmfStateStatistics(this) );
+ } catch (TmfTraceException e) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
+ }
+ return Status.OK_STATUS;
}
/**
* Suppressing the warning, because the 'throws' will usually happen in
* sub-classes.
*
- * @throws TmfTraceException
- * If there is a problem during the build
- * @since 2.0
+ * @return An IStatus indicating if the state system could be build
+ * successfully or not.
+ * @since 3.0
*/
- @SuppressWarnings("unused")
- protected void buildStateSystem() throws TmfTraceException {
+ protected IStatus buildStateSystem() {
/*
* Nothing is done in the base implementation, please specify
* how/if to register a new state system in derived classes.
*/
- return;
+ return Status.OK_STATUS;
}
/**
/**
* @return the trace indexer
+ * @since 3.0
*/
protected ITmfTraceIndexer getIndexer() {
return fIndexer;
return new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
}
+ /**
+ * @since 3.0
+ */
+ @Override
+ public String getHostId() {
+ return this.getName();
+ }
+
// ------------------------------------------------------------------------
// Convenience setters
// ------------------------------------------------------------------------
* Set the trace indexer. Must be done at initialization time.
*
* @param indexer the trace indexer
+ * @since 3.0
*/
protected void setIndexer(final ITmfTraceIndexer indexer) {
fIndexer = indexer;
* The signal is either for this trace, or for an experiment containing
* this trace.
*/
- try {
- buildStatistics();
- buildStateSystem();
- } catch (TmfTraceException e) {
- e.printStackTrace();
+ MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, null, null);
+ status.add(buildStatistics());
+ status.add(buildStateSystem());
+ if (!status.isOK()) {
+ Activator.log(status);
}
/* Refresh the project, so it can pick up new files that got created. */
}
}
+ /**
+ * Returns the file resource used to store synchronization formula. The file
+ * may not exist.
+ *
+ * @return the synchronization file
+ */
+ private File getSyncFormulaFile() {
+ File file = null;
+ if (fResource instanceof IFolder) {
+ try {
+ String supplDirectory;
+
+ supplDirectory = fResource.getPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER);
+
+ file = new File(supplDirectory + File.separator + SYNCHRONIZATION_FORMULA_FILE);
+
+ } catch (CoreException e) {
+
+ }
+ }
+ return file;
+ }
+
+ // ------------------------------------------------------------------------
+ // Timestamp transformation functions
+ // ------------------------------------------------------------------------
+
+ /**
+ * @since 3.0
+ */
+ @Override
+ public ITmfTimestampTransform getTimestampTransform() {
+ if (fTsTransform == null) {
+ /* Check if a formula is stored somewhere in the resources */
+ File sync_file = getSyncFormulaFile();
+ if (sync_file != null && sync_file.exists()) {
+
+ try {
+ FileInputStream fis = new FileInputStream(sync_file);
+ ObjectInputStream ois = new ObjectInputStream(fis);
+ fTsTransform = (ITmfTimestampTransform) ois.readObject();
+
+ ois.close();
+ fis.close();
+ } catch (ClassNotFoundException e1) {
+ fTsTransform = TmfTimestampTransform.IDENTITY;
+ } catch (FileNotFoundException e1) {
+ fTsTransform = TmfTimestampTransform.IDENTITY;
+ } catch (IOException e1) {
+ fTsTransform = TmfTimestampTransform.IDENTITY;
+ }
+ } else {
+ fTsTransform = TmfTimestampTransform.IDENTITY;
+ }
+ }
+ return fTsTransform;
+ }
+
+ /**
+ * @since 3.0
+ */
+ @Override
+ public void setTimestampTransform(final ITmfTimestampTransform tt) {
+ fTsTransform = tt;
+
+ /* Save the timestamp transform to a file */
+ File sync_file = getSyncFormulaFile();
+ if (sync_file != null) {
+ if (sync_file.exists()) {
+ sync_file.delete();
+ }
+ FileOutputStream fos;
+ ObjectOutputStream oos;
+
+ /* Save the header of the file */
+ try {
+ fos = new FileOutputStream(sync_file, false);
+ oos = new ObjectOutputStream(fos);
+
+ oos.writeObject(fTsTransform);
+ oos.close();
+ fos.close();
+ } catch (IOException e1) {
+ Activator.logError("Error writing timestamp transform for trace", e1); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * @since 3.0
+ */
+ @Override
+ public ITmfTimestamp createTimestamp(long ts) {
+ return new TmfTimestamp(getTimestampTransform().transform(ts));
+ }
+
// ------------------------------------------------------------------------
// toString
// ------------------------------------------------------------------------
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.indexer;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * The generic trace indexer in TMF with support for incremental indexing.
+ *
+ * @see ITmfTrace
+ * @see ITmfEvent
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public interface ITmfTraceIndexer {
+
+ /**
+ * Start an asynchronous index building job and waits for the job completion
+ * if required. Typically, the indexing job sends notifications at regular
+ * intervals to indicate its progress.
+ * <p>
+ * <b>Example 1</b>: Index a whole trace asynchronously
+ *
+ * <pre>
+ * trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, false);
+ * </pre>
+ *
+ * <b>Example 2</b>: Index a whole trace synchronously
+ *
+ * <pre>
+ * trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
+ * </pre>
+ *
+ * <b>Example 3</b>: Index a trace asynchronously, starting at rank 100
+ *
+ * <pre>
+ * trace.getIndexer().buildIndex(100, TmfTimeRange.ETERNITY, false);
+ * </pre>
+ *
+ * <b>Example 4</b>: Index a trace asynchronously, starting at rank 100 for
+ * events between T1 and T2 (inclusive). This is used for incremental
+ * indexing.
+ *
+ * <pre>
+ * TmfTimeRange range = new TmfTimeRange(T1, T2);
+ * trace.getIndexer().buildIndex(100, range, false);
+ * </pre>
+ *
+ * @param offset
+ * The offset of the first event to consider
+ * @param range
+ * The time range to consider
+ * @param waitForCompletion
+ * Should we block the calling thread until the build is
+ * complete?
+ * @since 2.0
+ */
+ void buildIndex(long offset, TmfTimeRange range, boolean waitForCompletion);
+
+ /**
+ * Indicates that the indexer is busy indexing the trace.
+ * Will always return false if the indexing is done synchronously.
+ *
+ * @return the state of the indexer (indexing or not)
+ */
+ boolean isIndexing();
+
+ /**
+ * Adds an entry to the trace index.
+ *
+ * @param context The trace context to save
+ * @param timestamp The timestamp matching this context
+ * @since 2.0
+ */
+ void updateIndex(ITmfContext context, ITmfTimestamp timestamp);
+
+ /**
+ * Returns the context of the checkpoint immediately preceding the requested
+ * timestamp (or at the timestamp if it coincides with a checkpoint).
+ *
+ * @param timestamp the requested timestamp
+ * @return the checkpoint context
+ * @since 2.0
+ */
+ ITmfContext seekIndex(ITmfTimestamp timestamp);
+
+ /**
+ * Returns the context of the checkpoint immediately preceding the requested
+ * rank (or at rank if it coincides with a checkpoint).
+ *
+ * @param rank the requested event rank
+ * @return the checkpoint context
+ */
+ ITmfContext seekIndex(long rank);
+
+ /**
+ * Perform cleanup when the indexer is no longer required.
+ */
+ void dispose();
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Patrick Tasse - Updated for location in checkpoint
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint;
+
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+
+/**
+ * The basic trace checkpoint structure in TMF. The purpose of the checkpoint is
+ * to associate a trace location to an event timestamp.
+ * *
+ * @see ITmfTimestamp
+ * @see ITmfLocation
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public interface ITmfCheckpoint extends Comparable<ITmfCheckpoint> {
+
+ // ------------------------------------------------------------------------
+ // Getters
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return the timestamp of the event referred to by the context
+ * @since 2.0
+ */
+ ITmfTimestamp getTimestamp();
+
+ /**
+ * @return the location of the event referred to by the checkpoint
+ */
+ ITmfLocation getLocation();
+
+ // ------------------------------------------------------------------------
+ // Comparable
+ // ------------------------------------------------------------------------
+
+ @Override
+ int compareTo(ITmfCheckpoint checkpoint);
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Updated as per TMF Trace Model 1.0
+ * Patrick Tasse - Updated for location in checkpoint
+ ******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint;
+
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+
+/**
+ * A basic implementation of ITmfCheckpoint. It simply maps an event timestamp
+ * to a generic location.
+ *
+ * @see ITmfLocation
+ * @see ITmfTimestamp
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public class TmfCheckpoint implements ITmfCheckpoint {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ // The checkpoint location
+ private final ITmfLocation fLocation;
+
+ // The checkpoint timestamp
+ private final ITmfTimestamp fTimestamp;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Full constructor
+ *
+ * @param timestamp the checkpoint timestamp
+ * @param location the corresponding trace location
+ * @since 3.0
+ */
+ public TmfCheckpoint(final ITmfTimestamp timestamp, final ITmfLocation location) {
+ fTimestamp = timestamp;
+ fLocation = location;
+ }
+
+ /**
+ * Copy constructor
+ *
+ * @param other the other checkpoint
+ */
+ public TmfCheckpoint(final TmfCheckpoint other) {
+ if (other == null) {
+ throw new IllegalArgumentException();
+ }
+ fTimestamp = other.fTimestamp;
+ fLocation = other.fLocation;
+ }
+
+ // ------------------------------------------------------------------------
+ // ITmfCheckpoint
+ // ------------------------------------------------------------------------
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public ITmfTimestamp getTimestamp() {
+ return fTimestamp;
+ }
+
+ @Override
+ public ITmfLocation getLocation() {
+ return fLocation;
+ }
+
+ // ------------------------------------------------------------------------
+ // Comparable
+ // ------------------------------------------------------------------------
+
+ @Override
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public int compareTo(final ITmfCheckpoint other) {
+ int comp = 0;
+ if ((fTimestamp != null) && (other.getTimestamp() != null)) {
+ comp = fTimestamp.compareTo(other.getTimestamp(), false);
+ if (comp != 0) {
+ return comp;
+ }
+ // compare locations if timestamps are the same
+ }
+
+ if ((fLocation == null) && (other.getLocation() == null)) {
+ return 0;
+ }
+
+ // treat location of other as null location which is before any location
+ if ((fLocation != null) && (other.getLocation() == null)) {
+ return 1;
+ }
+
+ // treat this as null location which is before any other locations
+ if ((fLocation == null) && (other.getLocation() != null)) {
+ return -1;
+ }
+
+ // compare location
+ final Comparable location1 = getLocation().getLocationInfo();
+ final Comparable location2 = other.getLocation().getLocationInfo();
+ return location1.compareTo(location2);
+ }
+
+ // ------------------------------------------------------------------------
+ // Object
+ // ------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((fLocation == null) ? 0 : fLocation.hashCode());
+ result = prime * result + ((fTimestamp == null) ? 0 : fTimestamp.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj instanceof TmfCheckpoint)) {
+ return false;
+ }
+ final TmfCheckpoint other = (TmfCheckpoint) obj;
+ if (fLocation == null) {
+ if (other.fLocation != null) {
+ return false;
+ }
+ } else if (!fLocation.equals(other.fLocation)) {
+ return false;
+ }
+ if (fTimestamp == null) {
+ if (other.fTimestamp != null) {
+ return false;
+ }
+ } else if (!fTimestamp.equals(other.fTimestamp)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ @SuppressWarnings("nls")
+ public String toString() {
+ return getClass().getSimpleName() + " [fLocation=" + fLocation + ", fTimestamp=" + fTimestamp + "]";
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.indexer.checkpoint;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.linuxtools.internal.tmf.core.Messages;
+import org.eclipse.linuxtools.tmf.core.component.TmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+
+/**
+ * A simple indexer that manages the trace index as an array of trace
+ * checkpoints. Checkpoints are stored at fixed intervals (event rank) in
+ * ascending timestamp order.
+ * <p>
+ * The goal being to access a random trace event reasonably fast from the user's
+ * standpoint, picking the right interval value becomes a trade-off between speed
+ * and memory usage (a shorter inter-event interval is faster but requires more
+ * checkpoints).
+ * <p>
+ * Locating a specific checkpoint is trivial for both rank (rank % interval) and
+ * timestamp (bsearch in the array).
+ * *
+ * @see ITmfTrace
+ * @see ITmfEvent
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public class TmfCheckpointIndexer implements ITmfTraceIndexer {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /** The event trace to index */
+ protected final ITmfTrace fTrace;
+
+ /** The interval between checkpoints */
+ private final int fCheckpointInterval;
+
+ /** The event trace to index */
+ private boolean fIsIndexing;
+
+ /**
+ * The trace index. It is composed of checkpoints taken at intervals of
+ * fCheckpointInterval events.
+ */
+ protected final List<ITmfCheckpoint> fTraceIndex;
+
+ /**
+ * The indexing request
+ */
+ private ITmfEventRequest fIndexingRequest = null;
+
+ // ------------------------------------------------------------------------
+ // Construction
+ // ------------------------------------------------------------------------
+
+ /**
+ * Basic constructor that uses the default trace block size as checkpoints
+ * intervals
+ *
+ * @param trace the trace to index
+ */
+ public TmfCheckpointIndexer(final ITmfTrace trace) {
+ this(trace, TmfDataProvider.DEFAULT_BLOCK_SIZE);
+ }
+
+ /**
+ * Full trace indexer
+ *
+ * @param trace the trace to index
+ * @param interval the checkpoints interval
+ */
+ public TmfCheckpointIndexer(final ITmfTrace trace, final int interval) {
+ fTrace = trace;
+ fCheckpointInterval = interval;
+ fTraceIndex = new ArrayList<ITmfCheckpoint>();
+ fIsIndexing = false;
+ }
+
+ @Override
+ public void dispose() {
+ if ((fIndexingRequest != null) && !fIndexingRequest.isCompleted()) {
+ fIndexingRequest.cancel();
+ fTraceIndex.clear();
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // ITmfTraceIndexer - isIndexing
+ // ------------------------------------------------------------------------
+
+ @Override
+ public boolean isIndexing() {
+ return fIsIndexing;
+ }
+
+ // ------------------------------------------------------------------------
+ // ITmfTraceIndexer - buildIndex
+ // ------------------------------------------------------------------------
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public void buildIndex(final long offset, final TmfTimeRange range, final boolean waitForCompletion) {
+
+ // Don't do anything if we are already indexing
+ synchronized (fTraceIndex) {
+ if (fIsIndexing) {
+ return;
+ }
+ fIsIndexing = true;
+ }
+
+ // The monitoring job
+ final Job job = new Job("Indexing " + fTrace.getName() + "...") { //$NON-NLS-1$ //$NON-NLS-2$
+ @Override
+ protected IStatus run(final IProgressMonitor monitor) {
+ monitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+ while (!monitor.isCanceled()) {
+ try {
+ long prevNbEvents = fTrace.getNbEvents();
+ Thread.sleep(250);
+ long nbEvents = fTrace.getNbEvents();
+ setName(Messages.TmfCheckpointIndexer_Indexing + ' ' + fTrace.getName() + " (" + nbEvents + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ // setName doesn't refresh the UI, setTaskName does
+ long rate = (nbEvents - prevNbEvents) * 4;
+ monitor.setTaskName(rate + " " + Messages.TmfCheckpointIndexer_EventsPerSecond); //$NON-NLS-1$
+ } catch (final InterruptedException e) {
+ return Status.OK_STATUS;
+ }
+ }
+ monitor.done();
+ return Status.OK_STATUS;
+ }
+ };
+ job.schedule();
+
+ // Build a background request for all the trace data. The index is
+ // updated as we go by readNextEvent().
+ fIndexingRequest = new TmfEventRequest(ITmfEvent.class,
+ range, offset, TmfDataRequest.ALL_DATA,
+ ITmfDataRequest.ExecutionType.BACKGROUND) {
+ @Override
+ public void handleData(final ITmfEvent event) {
+ super.handleData(event);
+ if (event != null) {
+ // Update the trace status at regular intervals
+ if ((getNbRead() % fCheckpointInterval) == 0) {
+ updateTraceStatus();
+ }
+ }
+ }
+
+ @Override
+ public void handleSuccess() {
+ updateTraceStatus();
+ }
+
+ @Override
+ public void handleCompleted() {
+ job.cancel();
+ super.handleCompleted();
+ fIsIndexing = false;
+ }
+
+ private void updateTraceStatus() {
+ if (fTrace.getNbEvents() > 0) {
+ signalNewTimeRange(fTrace.getStartTime(), fTrace.getEndTime());
+ }
+ }
+ };
+
+ // Submit the request and wait for completion if required
+ fTrace.sendRequest(fIndexingRequest);
+ if (waitForCompletion) {
+ try {
+ fIndexingRequest.waitForCompletion();
+ } catch (final InterruptedException e) {
+ }
+ }
+ }
+
+ /**
+ * Notify the interested parties that the trace time range has changed
+ *
+ * @param startTime the new start time
+ * @param endTime the new end time
+ */
+ private void signalNewTimeRange(final ITmfTimestamp startTime, final ITmfTimestamp endTime) {
+ fTrace.broadcast(new TmfTraceUpdatedSignal(fTrace, fTrace, new TmfTimeRange(startTime, endTime)));
+ }
+
+ // ------------------------------------------------------------------------
+ // ITmfTraceIndexer - updateIndex
+ // ------------------------------------------------------------------------
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public synchronized void updateIndex(final ITmfContext context, final ITmfTimestamp timestamp) {
+ if ((context.getRank() % fCheckpointInterval) == 0) {
+ // Determine the table position
+ final long position = context.getRank() / fCheckpointInterval;
+ // Add new entry at proper location (if empty)
+ if (fTraceIndex.size() == position) {
+ fTraceIndex.add(new TmfCheckpoint(timestamp, context.getLocation()));
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // ITmfTraceIndexer - seekIndex
+ // ------------------------------------------------------------------------
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public synchronized ITmfContext seekIndex(final ITmfTimestamp timestamp) {
+
+ // A null timestamp indicates to seek the first event
+ if (timestamp == null) {
+ return fTrace.seekEvent(0);
+ }
+
+ // Find the checkpoint at or before the requested timestamp.
+ // In the very likely event that the timestamp is not at a checkpoint
+ // boundary, bsearch will return index = (- (insertion point + 1)).
+ // It is then trivial to compute the index of the previous checkpoint.
+ int index = Collections.binarySearch(fTraceIndex, new TmfCheckpoint(timestamp, null));
+ if (index < 0) {
+ index = Math.max(0, -(index + 2));
+ } else {
+ // If timestamp was in the list, use previous index to be able to find the
+ // first event with the same timestamp before the checkpoint
+ index = Math.max(0, index - 1);
+ }
+
+ // Position the trace at the checkpoint
+ return restoreCheckpoint(index);
+ }
+
+ @Override
+ public ITmfContext seekIndex(final long rank) {
+
+ // A rank < 0 indicates to seek the first event
+ if (rank < 0) {
+ return fTrace.seekEvent(0);
+ }
+
+ // Find the checkpoint at or before the requested rank.
+ final int index = (int) rank / fCheckpointInterval;
+
+ // Position the trace at the checkpoint
+ return restoreCheckpoint(index);
+ }
+
+ /**
+ * Position the trace at the given checkpoint
+ *
+ * @param checkpoint the checkpoint index
+ * @return the corresponding context
+ */
+ private ITmfContext restoreCheckpoint(final int checkpoint) {
+ ITmfLocation location = null;
+ int index = 0;
+ synchronized (fTraceIndex) {
+ if (!fTraceIndex.isEmpty()) {
+ index = checkpoint;
+ if (index >= fTraceIndex.size()) {
+ index = fTraceIndex.size() - 1;
+ }
+ location = fTraceIndex.get(index).getLocation();
+ }
+ }
+ final ITmfContext context = fTrace.seekEvent(location);
+ context.setRank((long) index * fCheckpointInterval);
+ return context;
+ }
+
+ // ------------------------------------------------------------------------
+ // Getters
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return the trace index
+ */
+ protected List<ITmfCheckpoint> getTraceIndex() {
+ return fTraceIndex;
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Updated as per TMF Trace Model 1.0
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.location;
+
+/**
+ * The generic trace location in TMF.
+ * <p>
+ * An ITmfLocation is the equivalent of a random-access file position, holding
+ * enough information to allow the positioning of the trace 'pointer' to read an
+ * arbitrary event.
+ * <p>
+ * This location is trace-specific, must be comparable and immutable.
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public interface ITmfLocation {
+
+ // ------------------------------------------------------------------------
+ // Getters
+ // ------------------------------------------------------------------------
+
+ /**
+ * Returns the concrete trace location information
+ *
+ * @return the location information
+ * @since 2.0
+ */
+ Comparable<?> getLocationInfo();
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ * Francois Chouinard - Updated as per TMF Trace Model 1.0
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.location;
+
+
+/**
+ * A abstract implementation of ITmfLocation. The concrete classes must provide
+ * comparable location information.
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public abstract class TmfLocation implements ITmfLocation {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ private final Comparable<?> fLocationInfo;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Standard constructor.
+ *
+ * @param locationInfo
+ * The concrete trace location
+ */
+ public TmfLocation(final Comparable<?> locationInfo) {
+ fLocationInfo = locationInfo;
+ }
+
+ /**
+ * Copy constructor
+ *
+ * @param location
+ * The original trace location
+ */
+ public TmfLocation(final TmfLocation location) {
+ fLocationInfo = location.fLocationInfo;
+ }
+
+ // ------------------------------------------------------------------------
+ // Getters
+ // ------------------------------------------------------------------------
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public Comparable<?> getLocationInfo() {
+ return fLocationInfo;
+ }
+
+ // ------------------------------------------------------------------------
+ // Object
+ // ------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((fLocationInfo != null) ? fLocationInfo.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TmfLocation other = (TmfLocation) obj;
+ if (fLocationInfo == null) {
+ if (other.fLocationInfo != null) {
+ return false;
+ }
+ } else if (!fLocationInfo.equals(other.fLocationInfo)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ @SuppressWarnings("nls")
+ public String toString() {
+ return getClass().getSimpleName() + " [fLocationInfo=" + fLocationInfo + "]";
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.location;
+
+
+/**
+ * A concrete implementation of TmfLocation based on Long:s
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public final class TmfLongLocation extends TmfLocation {
+
+ /**
+ * The normal constructor
+ *
+ * @param locationInfo the concrete location
+ */
+ public TmfLongLocation(final Long locationInfo) {
+ super(locationInfo);
+ }
+
+ /**
+ * The copy constructor
+ *
+ * @param other the other location
+ */
+ public TmfLongLocation(final TmfLongLocation other) {
+ super(other.getLocationInfo());
+ }
+
+ @Override
+ public Long getLocationInfo() {
+ return (Long) super.getLocationInfo();
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace.location;
+
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+
+/**
+ * A concrete implementation of TmfLocation based on ITmfTimestamp:s
+ *
+ * @author Francois Chouinard
+ * @since 3.0
+ */
+public final class TmfTimestampLocation extends TmfLocation {
+
+ /**
+ * The normal constructor
+ *
+ * @param locationInfo the concrete location
+ */
+ public TmfTimestampLocation(final ITmfTimestamp locationInfo) {
+ super(locationInfo);
+ }
+
+ /**
+ * The copy constructor
+ *
+ * @param other the other location
+ */
+ public TmfTimestampLocation(final TmfTimestampLocation other) {
+ super(other.getLocationInfo());
+ }
+
+ @Override
+ public ITmfTimestamp getLocationInfo() {
+ return (ITmfTimestamp) super.getLocationInfo();
+ }
+
+}
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.tmf.help; singleton:=true
Require-Bundle: org.eclipse.help
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.tmf.help</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools TMF Help Plug-in</name>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.tmf.ui.tests;singleton:=true
Bundle-ActivationPolicy: lazy
org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources,
- org.eclipse.linuxtools.tmf.core;bundle-version="2.1.0",
- org.eclipse.linuxtools.tmf.ui;bundle-version="2.1.0",
- org.eclipse.linuxtools.tmf.core.tests;bundle-version="2.1.0"
+ org.eclipse.linuxtools.tmf.core;bundle-version="3.0.0",
+ org.eclipse.linuxtools.tmf.ui;bundle-version="3.0.0",
+ org.eclipse.linuxtools.tmf.core.tests;bundle-version="3.0.0"
Export-Package: org.eclipse.linuxtools.tmf.ui.tests
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.tmf.ui.tests</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<name>Linux Tools TMF UI Tests Plug-in</name>
// Create test trace object
final URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path("tracesets/sdEvents"), null);
final File test = new File(FileLocator.toFileURL(location).toURI());
- return new TmfTraceStub(test.getPath(), 500, true, parser, null);
+ return new TmfTraceStub(test.getPath(), 500, true, null, parser);
} catch (final TmfTraceException e) {
e.printStackTrace();
throw new RuntimeException(e);
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.linuxtools.tmf.ui;singleton:=true
Bundle-Activator: org.eclipse.linuxtools.internal.tmf.ui.Activator
Require-Bundle: org.eclipse.core.expressions,
org.eclipse.core.resources,
org.eclipse.core.runtime,
- org.eclipse.linuxtools.tmf.core;bundle-version="2.1.0",
+ org.eclipse.linuxtools.tmf.core;bundle-version="3.0.0",
org.eclipse.ui,
org.eclipse.ui.ide,
org.eclipse.ui.navigator,
org.eclipse.linuxtools.tmf.ui.views.callstack,
org.eclipse.linuxtools.tmf.ui.views.colors,
org.eclipse.linuxtools.tmf.ui.views.distribution.model,
- org.eclipse.linuxtools.tmf.ui.views.environment,
org.eclipse.linuxtools.tmf.ui.views.filter,
org.eclipse.linuxtools.tmf.ui.views.histogram,
org.eclipse.linuxtools.tmf.ui.views.statesystem,
org.eclipse.linuxtools.tmf.ui.views.statistics,
+ org.eclipse.linuxtools.tmf.ui.views.synchronization,
org.eclipse.linuxtools.tmf.ui.views.timechart,
org.eclipse.linuxtools.tmf.ui.views.timegraph,
org.eclipse.linuxtools.tmf.ui.views.uml2sd,
events.editor.name = Events Editor
uml2sd.view.name = Sequence Diagram
histogram.view.name = Histogram
-environment.view.name = Environment Variables
ssvisualizer.view.name = State System Explorer
callstack.view.name = Call Stack
+synchronization.view.name = Synchronization
+
# Tracing wizards
project.new.category.name = Tracing
command.batch_import.mnemonic = B
command.batch_import.descriptio = Batch Import
+command.synchronize_traces = Synchronize Traces
+command.synchronize_traces.mnemonic = y
+command.synchronize_traces.description = Synchronize 2 or more traces
+
## Trace menu
# Open, Copy, Rename, Delete, Delete Supplementary Files, Select Trace Type
id="org.eclipse.linuxtools.tmf.ui.views.timechart"
name="%timechart.view.name"
restorable="true">
- </view>
- <view
- allowMultiple="false"
- category="org.eclipse.linuxtools.tmf.ui.views.category"
- class="org.eclipse.linuxtools.tmf.ui.views.environment.TmfEnvironmentView"
- icon="icons/eview16/events_view.gif"
- id="org.eclipse.linuxtools.tmf.ui.views.environment"
- name="%environment.view.name"
- restorable="true">
</view>
<view
allowMultiple="false"
name="%callstack.view.name"
restorable="true">
</view>
+ <view
+ allowMultiple="false"
+ category="org.eclipse.linuxtools.tmf.ui.views.category"
+ class="org.eclipse.linuxtools.tmf.ui.views.synchronization.TmfSynchronizationView"
+ icon="icons/eview16/synced.gif"
+ id="org.eclipse.linuxtools.tmf.ui.views.synchronization"
+ name="%synchronization.view.name"
+ restorable="true">
+ </view>
</extension>
<extension
point="org.eclipse.ui.editors">
</with>
</visibleWhen>
</command>
+ <command
+ commandId="org.eclipse.linuxtools.tmf.ui.command.synchronize_traces"
+ icon="icons/obj16/add_obj.gif"
+ label="%command.synchronize_traces"
+ mnemonic="%command.synchronize_traces.mnemonic"
+ style="push"
+ tooltip="%commands.synchronize_traces.description">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
<separator
name="org.eclipse.linuxtools.tmf.ui.separator5"
visible="true">
id="org.eclipse.linuxtools.tmf.ui.command.select_traces"
name="%command.select_traces">
</command>
+ <command
+ categoryId="org.eclipse.linuxtools.tmf.ui.commands.category"
+ description="%command.synchronize_traces.description"
+ id="org.eclipse.linuxtools.tmf.ui.command.synchronize_traces"
+ name="%command.synchronize_traces">
+ </command>
<category
description="%commands.parser.category.description"
id="org.eclipse.linuxtools.tmf.ui.commands.parser.category"
</and>
</activeWhen>
</handler>
+ <handler
+ class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.SynchronizeTracesHandler"
+ commandId="org.eclipse.linuxtools.tmf.ui.command.synchronize_traces">
+ <activeWhen>
+ <and>
+ <count
+ value="1">
+ </count>
+ <iterate
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement">
+ </instanceof>
+ </iterate>
+ </and>
+ </activeWhen>
+ </handler>
<handler
class="org.eclipse.linuxtools.internal.tmf.ui.commands.ManageCustomParsersCommandHandler"
commandId="org.eclipse.linuxtools.tmf.ui.command.managecustomparsers">
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.tmf.ui</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>Linux Tools TMF UI Plug-in</name>
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
/**
* Base class for custom plain text traces.
import java.util.regex.Matcher;
import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* Trace context for custom text traces.
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceIndexer;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.TmfLongLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
+import org.eclipse.linuxtools.tmf.core.trace.location.TmfLongLocation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
/**
* Trace context for custom XML traces.
public static String DeleteExperimentHandler_Error;
public static String SelectTraceTypeHandler_ErrorSelectingTrace;
-
public static String SelectTraceTypeHandler_Title;
-
public static String SelectTraceTypeHandler_TraceFailedValidation;
-
public static String SelectTraceTypeHandler_TracesFailedValidation;
public static String SelectTraceTypeHandler_InvalidTraceType;
public static String DropAdapterAssistant_RenameTraceTitle;
public static String DropAdapterAssistant_RenameTraceMessage;
+ public static String SynchronizeTracesHandler_InitError;
+ public static String SynchronizeTracesHandler_CopyProblem;
+ public static String SynchronizeTracesHandler_WrongType;
+ public static String SynchronizeTracesHandler_WrongTraceNumber;
+ public static String SynchronizeTracesHandler_Title;
+ public static String SynchronizeTracesHandler_Error;
+ public static String SynchronizeTracesHandler_ErrorSynchingExperiment;
+ public static String SynchronizeTracesHandler_ErrorSynchingForTrace;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.project.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.synchronization.SynchronizationAlgorithm;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
+import org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
+import org.eclipse.linuxtools.tmf.ui.project.model.TraceUtils;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Handles the synchronization of an experiment, when the user selects this
+ * option in the menu
+ */
+public class SynchronizeTracesHandler extends AbstractHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ private TreeSelection fSelection = null;
+ private static final String CR = System.getProperty("line.separator"); //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Validation
+ // ------------------------------------------------------------------------
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ // ------------------------------------------------------------------------
+ // Execution
+ // ------------------------------------------------------------------------
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ // Check if we are closing down
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) {
+ return null;
+ }
+
+ // Get the selection
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPart part = page.getActivePart();
+ if (part == null) {
+ return false;
+ }
+ ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
+ if (selectionProvider == null) {
+ return false;
+ }
+ ISelection selection = selectionProvider.getSelection();
+
+ // Make sure selection contains only traces
+ fSelection = null;
+ final ArrayList<TmfTraceElement> tl = new ArrayList<TmfTraceElement>();
+ final ArrayList<TmfExperimentElement> uiexperiment = new ArrayList<TmfExperimentElement>();
+ if (selection instanceof TreeSelection) {
+ fSelection = (TreeSelection) selection;
+ Iterator<Object> iterator = fSelection.iterator();
+ while (iterator.hasNext()) {
+ Object element = iterator.next();
+ if (element instanceof TmfTraceElement) {
+ tl.add((TmfTraceElement) element);
+ } else if (element instanceof TmfExperimentElement) {
+ TmfExperimentElement exp = (TmfExperimentElement) element;
+ uiexperiment.add(exp);
+ for (TmfTraceElement trace : exp.getTraces()) {
+ tl.add(trace);
+ }
+ }
+ }
+ }
+
+ if ((uiexperiment.size() == 1) && (tl.size() > 1)) {
+
+ Thread thread = new Thread() {
+ @Override
+ public void run() {
+
+ final ITmfTrace[] traces = new ITmfTrace[tl.size()];
+ final TmfExperimentElement exp = uiexperiment.get(0);
+
+ for (int i = 0; i < tl.size(); i++) {
+ ITmfTrace trace = tl.get(i).instantiateTrace();
+ ITmfEvent traceEvent = tl.get(i).instantiateEvent();
+ if (trace == null) {
+ TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.SynchronizeTracesHandler_WrongType + tl.get(i).getName());
+ for (int j = 0; j < i; j++) {
+ traces[j].dispose();
+ }
+ return;
+ }
+ try {
+ trace.initTrace(tl.get(i).getResource(), tl.get(i).getLocation().getPath(), traceEvent.getClass());
+ } catch (TmfTraceException e) {
+ TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.SynchronizeTracesHandler_InitError + CR + CR + e);
+ trace.dispose();
+ for (int j = 0; j < i; j++) {
+ traces[j].dispose();
+ }
+ return;
+ }
+ traces[i] = trace;
+ }
+
+ /*
+ * FIXME Unlike traces, there is no instanceExperiment, so
+ * we call this function here alone. Maybe it would be
+ * better to do this on experiment's element constructor?
+ */
+ exp.refreshSupplementaryFolder();
+ final TmfExperiment experiment = new TmfExperiment(ITmfEvent.class, exp.getName(), traces, exp.getResource());
+
+ try {
+ final SynchronizationAlgorithm syncAlgo = experiment.synchronizeTraces(true);
+
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ /*
+ * For each trace in the experiment, if there is
+ * a transform equation, copy the original
+ * trace, so that a new state system will be
+ * generated with sync time.
+ */
+ for (int i = 0; i < tl.size(); i++) {
+ TmfTraceElement traceel = tl.get(i);
+ try {
+ if (syncAlgo.isTraceSynced(traceel.getName())) {
+
+ /* Find the original trace */
+ TmfTraceElement origtrace = null;
+ for (ITmfProjectModelElement el : traceel.getProject().getTracesFolder().getTraces()) {
+ if (el.getName().equals(traceel.getName())) {
+ origtrace = (TmfTraceElement) el;
+ }
+ }
+
+ if (origtrace != null) {
+ /*
+ * Make sure a trace with the
+ * new name does not exist
+ */
+ String newname = traceel.getName();
+ boolean traceexists;
+ do {
+ traceexists = false;
+ newname += "_"; //$NON-NLS-1$
+ for (ITmfProjectModelElement el : traceel.getProject().getTracesFolder().getTraces()) {
+ if (el.getName().equals(newname)) {
+ traceexists = true;
+ }
+ }
+ } while (traceexists);
+
+ /* Copy the original trace */
+ TmfTraceElement newtrace = origtrace.copy(newname);
+
+ if (newtrace != null) {
+
+ syncAlgo.renameTrace(origtrace.getName(), newtrace.getName());
+
+ /*
+ * Instantiate the new trace
+ * and set its sync formula
+ */
+ ITmfTrace trace = newtrace.instantiateTrace();
+ ITmfEvent traceEvent = newtrace.instantiateEvent();
+
+ trace.initTrace(newtrace.getResource(), newtrace.getLocation().getPath(), traceEvent.getClass());
+ trace.setTimestampTransform(syncAlgo.getTimestampTransform(trace));
+
+ /*
+ * Add the new trace to the
+ * experiment
+ */
+ exp.addTrace(newtrace);
+
+ /*
+ * Delete the original trace
+ * element
+ */
+ exp.removeTrace(traceel);
+ } else {
+ TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.SynchronizeTracesHandler_Error + CR + CR + String.format(Messages.SynchronizeTracesHandler_CopyProblem, origtrace.getName()));
+ }
+ }
+ }
+ } catch (CoreException e) {
+ Activator.getDefault().logError(String.format(Messages.SynchronizeTracesHandler_ErrorSynchingForTrace, exp.getName(), traceel.getName()), e);
+ TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.SynchronizeTracesHandler_Error + CR + CR + e.getMessage());
+ } catch (TmfTraceException e) {
+ Activator.getDefault().logError(String.format(Messages.SynchronizeTracesHandler_ErrorSynchingForTrace, exp.getName(), traceel.getName()), e);
+ TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.SynchronizeTracesHandler_Error + CR + CR + e.getMessage());
+ }
+ }
+ }
+ });
+
+ } catch (TmfTraceException e) {
+ Activator.getDefault().logError(String.format(Messages.SynchronizeTracesHandler_ErrorSynchingExperiment, exp.getName()), e);
+ TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.SynchronizeTracesHandler_Error + CR + CR + e.getMessage());
+ }
+ }
+ };
+ thread.start();
+
+ } else {
+ TraceUtils.displayErrorMsg(Messages.SynchronizeTracesHandler_Title, Messages.SynchronizeTracesHandler_WrongTraceNumber);
+ }
+
+ return null;
+ }
+
+}
# Drag and drop
DropAdapterAssistant_RenameTraceTitle=Confirm rename trace
DropAdapterAssistant_RenameTraceMessage=A trace with the name ''{0}'' already exists in the target project.\nRename the dropped trace?
+
+# Trace synchronization
+SynchronizeTracesHandler_InitError=Error initializing trace
+SynchronizeTracesHandler_CopyProblem=Couldn't copy the original trace %s
+SynchronizeTracesHandler_WrongTraceNumber=Experiment must have more than one trace
+SynchronizeTracesHandler_Title=Synchronize traces
+SynchronizeTracesHandler_WrongType=Trace is not a kernel trace:\n
+SynchronizeTracesHandler_Error=Error synchronizing experiment
+
+SynchronizeTracesHandler_ErrorSynchingExperiment=Error synchronizing experiment %s
+SynchronizeTracesHandler_ErrorSynchingForTrace=Error synchronizing experiment %s for trace %s
* Base class for project elements who will have folder elements
* under them to store supplementary files.
*
- * @author gbastien
+ * @author Geneviève Bastien
* @since 2.0
*/
public abstract class TmfWithFolderElement extends TmfProjectModelElement {
if (TmfTrace.class.getCanonicalName().equals(member.getPersistentProperty(TmfCommonConstants.TRACETYPE))) {
member.delete(true, null);
}
- if (TmfExperiment.class.getCanonicalName().equals(member.getPersistentProperty(TmfCommonConstants.TRACETYPE))) {
+ else if (TmfExperiment.class.getCanonicalName().equals(member.getPersistentProperty(TmfCommonConstants.TRACETYPE))) {
member.delete(true, null);
}
}
int requestIndex;
DataRequest(Class<? extends ITmfEvent> dataType, ITmfFilter reqFilter, int start, int nbRequested) {
- super(dataType, start, nbRequested);
+ super(dataType, start, nbRequested,
+ TmfDataRequest.ExecutionType.FOREGROUND);
requestFilter = reqFilter;
requestRank = start;
requestIndex = index;
}
}
- TmfDataRequest request = new TmfDataRequest(ITmfEvent.class, startIndex, nbRequested) {
+ TmfDataRequest request = new TmfDataRequest(ITmfEvent.class,
+ startIndex,
+ nbRequested,
+ TmfDataRequest.ExecutionType.FOREGROUND) {
private int count = 0;
private long rank = startIndex;
@Override
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsCache.CachedEvent;
import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSetting;
import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;
return;
}
request = new TmfDataRequest(ITmfEvent.class, (int) fFilterCheckCount,
- nbRequested, fTrace.getCacheSize(), ExecutionType.BACKGROUND) {
+ nbRequested, ExecutionType.BACKGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
if (direction == Direction.BACKWARD) {
rank = Math.max(0, rank - fTrace.getCacheSize() + 1);
}
- request = new TmfDataRequest(ITmfEvent.class, (int) rank, nbRequested, fTrace.getCacheSize(), ExecutionType.BACKGROUND) {
+ request = new TmfDataRequest(ITmfEvent.class, (int) rank, nbRequested, ExecutionType.BACKGROUND) {
long currentRank = rank;
@Override
// Create a request for one event that will be queued after other ongoing requests. When this request is completed
// do the work to select the actual event with the timestamp specified in the signal. This procedure prevents
// the method fTrace.getRank() from interfering and delaying ongoing requests.
- final TmfDataRequest subRequest = new TmfDataRequest(ITmfEvent.class, 0, 1, ExecutionType.FOREGROUND) {
+ final TmfDataRequest subRequest = new TmfDataRequest(ITmfEvent.class,
+ 0, 1, ExecutionType.FOREGROUND) {
TmfTimestamp ts = new TmfTimestamp(signal.getBeginTime());
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial API and implementation
- * Bernd Hufmann - Updated to use Tree with columns to be able to group traces
- * Alexandre Montplaisir - Display info for any ITmfTraceProperties trace
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.ui.views.environment;
-
-import java.util.Map;
-
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
-import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal;
-import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
-import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceProperties;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
-import org.eclipse.linuxtools.tmf.ui.views.TmfView;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.swt.widgets.TreeItem;
-
-/**
- * Displays the trace's properties.
- *
- * @version 1.1
- * @author Matthew Khouzam
- */
-public class TmfEnvironmentView extends TmfView {
-
- /** The Environment View's ID */
- public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.environment"; //$NON-NLS-1$
-
- private ITmfTrace fTrace;
- private Tree fTree;
-
- /**
- * Default constructor
- */
- public TmfEnvironmentView() {
- super("EnvironmentVariables"); //$NON-NLS-1$
-// fTitlePrefix = getTitle();
- }
-
- // ------------------------------------------------------------------------
- // ViewPart
- // ------------------------------------------------------------------------
-
- @Override
- public void createPartControl(Composite parent) {
- fTree = new Tree(parent, SWT.NONE);
- TreeColumn nameCol = new TreeColumn(fTree, SWT.NONE, 0);
- TreeColumn valueCol = new TreeColumn(fTree, SWT.NONE, 1);
- nameCol.setText("Environment Variable"); //$NON-NLS-1$
- valueCol.setText("Value"); //$NON-NLS-1$
-
- fTree.setItemCount(0);
-
- fTree.setHeaderVisible(true);
- nameCol.pack();
- valueCol.pack();
-
- ITmfTrace trace = getActiveTrace();
- if (trace != null) {
- traceSelected(new TmfTraceSelectedSignal(this, trace));
- }
- }
-
- private void updateTable() {
- fTree.setItemCount(0);
- if (fTrace == null) {
- return;
- }
-
- for (ITmfTrace trace : TmfTraceManager.getTraceSet(fTrace)) {
- if (trace instanceof ITmfTraceProperties) {
- TreeItem item = new TreeItem(fTree, SWT.NONE);
- item.setText(0, trace.getName());
-
- ITmfTraceProperties propTrace = (ITmfTraceProperties) trace;
- Map <String, String> properties = propTrace.getTraceProperties();
- for (Map.Entry<String, String> entry : properties.entrySet()) {
- TreeItem subItem = new TreeItem(item, SWT.NONE);
- subItem.setText(0, entry.getKey()); // Variable name
- subItem.setText(1, entry.getValue()); // Variable value
- }
- }
- }
-
- // Expand the tree items
- for (int i = 0; i < fTree.getItemCount(); i++) {
- fTree.getItem(i).setExpanded(true);
- }
-
- for (TreeColumn column : fTree.getColumns()) {
- column.pack();
- }
- }
-
- @Override
- public void setFocus() {
- fTree.setFocus();
- }
-
- /**
- * Handler for the trace opened signal.
- * @param signal
- * The incoming signal
- * @since 2.0
- */
- @TmfSignalHandler
- public void traceOpened(TmfTraceOpenedSignal signal) {
- fTrace = signal.getTrace();
- updateTable();
- }
-
-
- /**
- * Handler for the trace selected signal.
- *
- * @param signal
- * The incoming signal
- * @since 2.0
- */
- @TmfSignalHandler
- public void traceSelected(TmfTraceSelectedSignal signal) {
- // Update the trace reference
- ITmfTrace trace = signal.getTrace();
- if (!trace.equals(fTrace)) {
- fTrace = trace;
- updateTable();
- }
- }
-
- /**
- * Handler for the trace closed signal.
- *
- * @param signal the incoming signal
- * @since 2.0
- */
- @TmfSignalHandler
- public void traceClosed(TmfTraceClosedSignal signal) {
- if (signal.getTrace() == fTrace) {
- fTrace = null;
- fTree.setItemCount(0);
- }
- }
-
-}
-
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
/**
* Class to request events for given time range from a trace to fill a HistogramDataModel and HistogramView.
public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range,
int rank, int nbEvents, int blockSize,
ITmfDataRequest.ExecutionType execType) {
- super(ITmfEvent.class, range, rank, nbEvents,
- (blockSize > 0) ? blockSize : ITmfTrace.DEFAULT_TRACE_CACHE_SIZE,
- execType);
+ super(ITmfEvent.class, range, rank, nbEvents, execType);
fHistogram = histogram;
}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.synchronization;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Message file for the synchronization view
+ * @since 3.0
+ */
+@SuppressWarnings("javadoc")
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.views.synchronization.messages"; //$NON-NLS-1$
+ public static String TmfSynchronizationView_NameColumn;
+ public static String TmfSynchronizationView_ValueColumn;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2013 École Polytechnique de Montréal
+ *
+ * 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:
+ * Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.synchronization;
+
+import java.util.Map;
+
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSynchronizedSignal;
+import org.eclipse.linuxtools.tmf.core.synchronization.SynchronizationAlgorithm;
+import org.eclipse.linuxtools.tmf.ui.views.TmfView;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * Small view to display statistics about a synchronization
+ *
+ * @author Geneviève Bastien
+ * @since 3.0
+ */
+public class TmfSynchronizationView extends TmfView {
+
+ /**
+ * The ID corresponds to the package in which this class is embedded.
+ */
+ public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.synchronization"; //$NON-NLS-1$
+
+ /**
+ * The view name.
+ */
+ public static final String TMF_SYNCHRONIZATION_VIEW = "SynchronizationView"; //$NON-NLS-1$
+
+ /**
+ * The synchronization algorithm to display stats for
+ */
+ private SynchronizationAlgorithm fAlgoSync;
+
+ private Tree fTree;
+
+ /**
+ * Default constructor
+ */
+ public TmfSynchronizationView() {
+ super(TMF_SYNCHRONIZATION_VIEW);
+ }
+
+ @Override
+ public void createPartControl(Composite parent) {
+ fTree = new Tree(parent, SWT.NONE);
+ TreeColumn nameCol = new TreeColumn(fTree, SWT.NONE, 0);
+ TreeColumn valueCol = new TreeColumn(fTree, SWT.NONE, 1);
+ nameCol.setText(Messages.TmfSynchronizationView_NameColumn);
+ valueCol.setText(Messages.TmfSynchronizationView_ValueColumn);
+
+ fTree.setItemCount(0);
+
+ fTree.setHeaderVisible(true);
+ nameCol.pack();
+ valueCol.pack();
+
+ }
+
+ private void updateTable() {
+ fTree.setItemCount(0);
+ if (fAlgoSync == null) {
+ return;
+ }
+
+ for (Map.Entry<String, Map<String, Object>> entry : fAlgoSync.getStats().entrySet()) {
+ TreeItem item = new TreeItem(fTree, SWT.NONE);
+ item.setText(0, entry.getKey().toString());
+ item.setText(1, entry.getValue().toString());
+
+ for (Map.Entry<String, Object> subentry : entry.getValue().entrySet()) {
+ TreeItem subitem = new TreeItem(item, SWT.NONE);
+ subitem.setText(0, subentry.getKey().toString());
+ subitem.setText(1, subentry.getValue().toString());
+ }
+ }
+
+ /* Expand the tree items */
+ for (int i = 0; i < fTree.getItemCount(); i++) {
+ fTree.getItem(i).setExpanded(true);
+ }
+
+ for (TreeColumn column : fTree.getColumns()) {
+ column.pack();
+ }
+ }
+
+ @Override
+ public void setFocus() {
+ fTree.setFocus();
+ }
+
+ /**
+ * Handler called when traces are synchronized
+ *
+ * @param signal
+ * Contains the information about the selection.
+ */
+ @TmfSignalHandler
+ public void traceSynchronized(TmfTraceSynchronizedSignal signal) {
+ if (signal.getSyncAlgo() != fAlgoSync) {
+ fAlgoSync = signal.getSyncAlgo();
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ updateTable();
+ }
+ });
+ }
+ }
+}
--- /dev/null
+TmfSynchronizationView_NameColumn=Synchronization Information
+TmfSynchronizationView_ValueColumn=Value
// ------------------------------------------------------------------------
// Constants
// ------------------------------------------------------------------------
+
/**
* Default title name.
*/
protected static final String TITLE = Messages.TmfUml2SDSyncLoader_ViewName;
- /**
- * Default block size for background request.
- */
- protected static final int DEFAULT_BLOCK_SIZE = 50000;
+
/**
* Maximum number of messages per page.
*/
TmfTimeRange window = TmfTimeRange.ETERNITY;
- fIndexRequest = new TmfEventRequest(ITmfEvent.class, window, TmfDataRequest.ALL_DATA, DEFAULT_BLOCK_SIZE, ITmfDataRequest.ExecutionType.BACKGROUND) {
+ fIndexRequest = new TmfEventRequest(ITmfEvent.class, window, 0, TmfDataRequest.ALL_DATA, ITmfDataRequest.ExecutionType.BACKGROUND) {
private ITmfTimestamp fFirstTime = null;
private ITmfTimestamp fLastTime = null;
window = TmfTimeRange.ETERNITY;
}
- fPageRequest = new TmfEventRequest(ITmfEvent.class, window, TmfDataRequest.ALL_DATA, 1, ITmfDataRequest.ExecutionType.FOREGROUND) {
+ fPageRequest = new TmfEventRequest(ITmfEvent.class, window, 0, TmfDataRequest.ALL_DATA, ITmfDataRequest.ExecutionType.FOREGROUND) {
private final List<ITmfSyncSequenceDiagramEvent> fSdEvent = new ArrayList<ITmfSyncSequenceDiagramEvent>();
@Override
*/
public SearchJob(Criteria findCriteria, TmfTimeRange window) {
super(Messages.TmfUml2SDSyncLoader_SearchJobDescrition);
- fSearchRequest = new SearchEventRequest(window, TmfDataRequest.ALL_DATA, 1, ITmfDataRequest.ExecutionType.FOREGROUND, findCriteria);
+ fSearchRequest = new SearchEventRequest(window, TmfDataRequest.ALL_DATA, ITmfDataRequest.ExecutionType.FOREGROUND, findCriteria);
}
@Override
* Constructor
* @param range @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#TmfEventRequest(...)
* @param nbRequested @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#handleData(...)
- * @param blockSize @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#handleData(...)
* @param execType @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#handleData(...)
* @param criteria The search criteria
*/
- public SearchEventRequest(TmfTimeRange range, int nbRequested, int blockSize, ExecutionType execType, Criteria criteria) {
- this(range, nbRequested, blockSize, execType, criteria, null);
+ public SearchEventRequest(TmfTimeRange range, int nbRequested, ExecutionType execType, Criteria criteria) {
+ this(range, nbRequested, execType, criteria, null);
}
/**
* Constructor
* @param range @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#TmfEventRequest(...)
* @param nbRequested @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#TmfEventRequest(...)
- * @param blockSize @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#TmfEventRequest(...)
* @param execType @see org.eclipse.linuxtools.tmf.request.TmfEventRequest#TmfEventRequest(...)
* @param criteria The search criteria
* @param monitor progress monitor
*/
- public SearchEventRequest(TmfTimeRange range, int nbRequested, int blockSize, ExecutionType execType, Criteria criteria, IProgressMonitor monitor) {
- super(ITmfEvent.class, range, nbRequested, blockSize, execType);
+ public SearchEventRequest(TmfTimeRange range, int nbRequested, ExecutionType execType, Criteria criteria, IProgressMonitor monitor) {
+ super(ITmfEvent.class, range, 0, nbRequested, execType);
fCriteria = new Criteria(criteria);
fMonitor = monitor;
}
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CaretEvent;
import org.eclipse.swt.custom.CaretListener;
<feature
id="org.eclipse.linuxtools.tmf"
label="%featureName"
- version="2.1.0.qualifier"
+ version="3.0.0.qualifier"
provider-name="%featureProvider"
license-feature="org.eclipse.linuxtools.license.feature"
license-feature-version="1.0.0.qualifier">
name="Common Trace Format (CTF)"/>
<requires>
- <import plugin="org.eclipse.linuxtools.ctf.core" version="2.1.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.ctf.core" version="3.0.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.ui.views"/>
<import plugin="org.eclipse.core.expressions"/>
- <import plugin="org.eclipse.linuxtools.tmf.core" version="2.1.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.linuxtools.tmf.core" version="3.0.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.ui"/>
<import plugin="org.eclipse.ui.ide"/>
<import plugin="org.eclipse.ui.navigator"/>
<parent>
<artifactId>linuxtools-lttng-parent</artifactId>
<groupId>org.eclipse.linuxtools.lttng</groupId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.linuxtools.tmf</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
<name>Linux Tools TMF (Tracing and Monitoring Framework) Feature</name>
incompatible_api_component_version=Error
incompatible_api_component_version_include_major_without_breaking_change=Disabled
incompatible_api_component_version_include_minor_without_api_change=Disabled
-invalid_since_tag_version=Error
+invalid_since_tag_version=Ignore
malformed_since_tag=Error
-missing_since_tag=Error
+missing_since_tag=Ignore
report_api_breakage_when_major_version_incremented=Disabled
report_resolution_errors_api_component=Warning
<groupId>org.eclipse.linuxtools.lttng</groupId>
<artifactId>linuxtools-lttng-parent</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Eclipse Linux Tools LTTng Parent</name>