From: Alexandre Montplaisir Date: Tue, 28 Oct 2014 23:16:47 +0000 (-0400) Subject: tmf: Move TmfExperiment to its own package X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=5c5fa260e7902d67ecb081b5fef9d46fe13933e1;p=deliverable%2Ftracecompass.git tmf: Move TmfExperiment to its own package With many experiment-specific concepts, and more on the way, it's making more sense to put TmfExperiment in its own package. Change-Id: I1ae03f693b075dd6e521fc20fb22d70b0c619551 Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/36208 Tested-by: Hudson CI Reviewed-by: Matthew Khouzam --- diff --git a/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/DsfGdbAdaptor.java b/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/DsfGdbAdaptor.java index 54e334e692..f13192abf5 100644 --- a/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/DsfGdbAdaptor.java +++ b/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/DsfGdbAdaptor.java @@ -88,7 +88,7 @@ import org.eclipse.tracecompass.tmf.core.event.TmfEventField; import org.eclipse.tracecompass.tmf.core.event.TmfEventType; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.ui.editors.ITmfTraceEditor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; diff --git a/org.eclipse.tracecompass.gdbtrace.ui/src/org/eclipse/tracecompass/internal/gdbtrace/ui/views/events/GdbEventsTable.java b/org.eclipse.tracecompass.gdbtrace.ui/src/org/eclipse/tracecompass/internal/gdbtrace/ui/views/events/GdbEventsTable.java index a73bbb6817..5c3e5d0eaf 100644 --- a/org.eclipse.tracecompass.gdbtrace.ui/src/org/eclipse/tracecompass/internal/gdbtrace/ui/views/events/GdbEventsTable.java +++ b/org.eclipse.tracecompass.gdbtrace.ui/src/org/eclipse/tracecompass/internal/gdbtrace/ui/views/events/GdbEventsTable.java @@ -28,7 +28,7 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfTimeSynchSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceUpdatedSignal; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable; /** diff --git a/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/event/matchandsync/ExperimentSyncTest.java b/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/event/matchandsync/ExperimentSyncTest.java index aeaa6f4460..d397e54fc7 100644 --- a/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/event/matchandsync/ExperimentSyncTest.java +++ b/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/event/matchandsync/ExperimentSyncTest.java @@ -22,7 +22,7 @@ import org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform; import org.eclipse.tracecompass.tmf.core.synchronization.SynchronizationAlgorithm; import org.eclipse.tracecompass.tmf.core.synchronization.TimestampTransformFactory; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace; import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; import org.junit.BeforeClass; diff --git a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/ExperimentStateSystemModuleTest.java b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/ExperimentStateSystemModuleTest.java index 82c772c88b..ff2540c0c2 100644 --- a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/ExperimentStateSystemModuleTest.java +++ b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/ExperimentStateSystemModuleTest.java @@ -26,7 +26,7 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule; import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestExperimentAnalysis; import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfExperimentStub; import org.junit.After; diff --git a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfExperimentTest.java b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfExperimentTest.java index 633c8d9ac6..4b05e658d4 100644 --- a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfExperimentTest.java +++ b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfExperimentTest.java @@ -29,14 +29,14 @@ import java.util.Vector; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; -import org.eclipse.tracecompass.internal.tmf.core.trace.TmfExperimentContext; -import org.eclipse.tracecompass.internal.tmf.core.trace.TmfExperimentLocation; +import org.eclipse.tracecompass.internal.tmf.core.trace.experiment.TmfExperimentContext; +import org.eclipse.tracecompass.internal.tmf.core.trace.experiment.TmfExperimentLocation; import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest; -import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest; import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType; +import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin; import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace; @@ -44,7 +44,7 @@ import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation; import org.eclipse.tracecompass.tmf.core.trace.location.TmfLongLocation; import org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestExperimentAnalysis; diff --git a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java index 3476a3f7aa..a2a5c22402 100644 --- a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java +++ b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java @@ -29,7 +29,7 @@ import java.util.Vector; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; -import org.eclipse.tracecompass.internal.tmf.core.trace.TmfExperimentContext; +import org.eclipse.tracecompass.internal.tmf.core.trace.experiment.TmfExperimentContext; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest; diff --git a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/location/TmfLocationTest.java b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/location/TmfLocationTest.java index 28ba7ea900..79a5d4d93e 100644 --- a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/location/TmfLocationTest.java +++ b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/location/TmfLocationTest.java @@ -21,8 +21,8 @@ import static org.junit.Assert.assertTrue; import java.nio.ByteBuffer; -import org.eclipse.tracecompass.internal.tmf.core.trace.TmfExperimentLocation; -import org.eclipse.tracecompass.internal.tmf.core.trace.TmfLocationArray; +import org.eclipse.tracecompass.internal.tmf.core.trace.experiment.TmfExperimentLocation; +import org.eclipse.tracecompass.internal.tmf.core.trace.experiment.TmfLocationArray; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation; import org.eclipse.tracecompass.tmf.core.trace.location.TmfLocation; diff --git a/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/TmfExperimentStub.java b/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/TmfExperimentStub.java index 5c645a5e5b..3c38619336 100644 --- a/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/TmfExperimentStub.java +++ b/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/TmfExperimentStub.java @@ -15,7 +15,7 @@ package org.eclipse.tracecompass.tmf.tests.stubs.trace; import org.eclipse.core.resources.IResource; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer; /** diff --git a/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF b/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF index eb450f5802..b9f2b17c45 100644 --- a/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF +++ b/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF @@ -20,7 +20,7 @@ Export-Package: org.eclipse.tracecompass.internal.tmf.core;x-friends:="org.eclip org.eclipse.tracecompass.internal.tmf.core.statesystem.mipmap;x-friends:="org.eclipse.tracecompass.tmf.core.tests", org.eclipse.tracecompass.internal.tmf.core.synchronization;x-friends:="org.eclipse.tracecompass.tmf.core.tests", org.eclipse.tracecompass.internal.tmf.core.synchronization.graph;x-friends:="org.eclipse.tracecompass.tmf.core.tests", - org.eclipse.tracecompass.internal.tmf.core.trace;x-friends:="org.eclipse.tracecompass.tmf.core.tests", + org.eclipse.tracecompass.internal.tmf.core.trace.experiment;x-friends:="org.eclipse.tracecompass.tmf.core.tests", org.eclipse.tracecompass.internal.tmf.core.trace.indexer;x-friends:="org.eclipse.tracecompass.tmf.core.tests", org.eclipse.tracecompass.tmf.core, org.eclipse.tracecompass.tmf.core.analysis, @@ -44,6 +44,7 @@ Export-Package: org.eclipse.tracecompass.internal.tmf.core;x-friends:="org.eclip org.eclipse.tracecompass.tmf.core.synchronization, org.eclipse.tracecompass.tmf.core.timestamp, org.eclipse.tracecompass.tmf.core.trace, + org.eclipse.tracecompass.tmf.core.trace.experiment, org.eclipse.tracecompass.tmf.core.trace.indexer, org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint, org.eclipse.tracecompass.tmf.core.trace.location, diff --git a/org.eclipse.tracecompass.tmf.core/plugin.xml b/org.eclipse.tracecompass.tmf.core/plugin.xml index 309a162773..c526d566a3 100644 --- a/org.eclipse.tracecompass.tmf.core/plugin.xml +++ b/org.eclipse.tracecompass.tmf.core/plugin.xml @@ -26,7 +26,7 @@ + class="org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment"> @@ -35,7 +35,7 @@ + experiment_type="org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment"> diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/TmfExperimentCheckpoint.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/TmfExperimentCheckpoint.java deleted file mode 100644 index 49c4fb4f0c..0000000000 --- a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/TmfExperimentCheckpoint.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * 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 - *******************************************************************************/ - -package org.eclipse.tracecompass.internal.tmf.core.trace; - -import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; -import org.eclipse.tracecompass.tmf.core.trace.TmfContext; - -/** - * TmfExperimentCheckpoint - *

- * TODO: Implement me. Please. - */ -public class TmfExperimentCheckpoint implements Comparable { - - // ------------------------------------------------------------------------ - // Attributes - // ------------------------------------------------------------------------ - - private final TmfTimestamp fTimestamp; - private final long[] fRanks; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - /** - * @param ts the checkpoint timestamp - * @param contexts the corresponding set of trace contexts - */ - public TmfExperimentCheckpoint(final TmfTimestamp ts, final TmfContext[] contexts) { - fTimestamp = ts; - fRanks = new long[contexts.length]; - for (int i = 0; i < fRanks.length; i++) { - fRanks[i] = contexts[i].getRank(); - } - } - - // ------------------------------------------------------------------------ - // Accessors - // ------------------------------------------------------------------------ - - /** - * @return the checkpoint event timestamp - */ - public TmfTimestamp getTimestamp() { - return fTimestamp; - } - - /** - * @return the checkpoint event rank - */ - public long[] getRanks() { - return fRanks; - } - - // ------------------------------------------------------------------------ - // Object - // ------------------------------------------------------------------------ - - @Override - public int hashCode() { - int result = 37; - result = 17 * result + fTimestamp.hashCode(); - return result; - } - - @Override - public boolean equals(final Object other) { - if (!(other instanceof TmfExperimentCheckpoint)) { - return false; - } - final TmfExperimentCheckpoint o = (TmfExperimentCheckpoint) other; - return fTimestamp.equals(o.fTimestamp); - } - - // ------------------------------------------------------------------------ - // Comparable - // ------------------------------------------------------------------------ - - @Override - public int compareTo(final TmfExperimentCheckpoint other) { - return fTimestamp.compareTo(other.fTimestamp); - } - -} diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/TmfExperimentContext.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/TmfExperimentContext.java deleted file mode 100644 index f86e75f358..0000000000 --- a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/TmfExperimentContext.java +++ /dev/null @@ -1,224 +0,0 @@ -/******************************************************************************* - * 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 - Put in shape for 1.0 - * Patrick Tasse - Updated for removal of context clone - *******************************************************************************/ - -package org.eclipse.tracecompass.internal.tmf.core.trace; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; -import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; -import org.eclipse.tracecompass.tmf.core.trace.TmfContext; - -/** - * The experiment context in TMF. - *

- * The experiment keeps track of the next event from each of its traces so it - * can pick the next one in chronological order. - *

- * This implies that the "next" event from each trace has already been - * read and that we at least know its timestamp. - *

- * The last trace refers to the trace from which the last event was "consumed" - * at the experiment level. - */ -public final class TmfExperimentContext extends TmfContext { - - // ------------------------------------------------------------------------ - // Constants - // ------------------------------------------------------------------------ - - /** - * No last trace read indicator - */ - public static final int NO_TRACE = -1; - - // ------------------------------------------------------------------------ - // Attributes - // ------------------------------------------------------------------------ - - private final List fContexts; - private final List fEvents; - private int fLastTraceRead; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - /** - * Standard constructor - * - * @param nbTraces - * The number of traces in the experiment - */ - public TmfExperimentContext(final int nbTraces) { - super(); - fLastTraceRead = NO_TRACE; - fContexts = new ArrayList<>(nbTraces); - fEvents = new ArrayList<>(nbTraces); - - - /* Initialize the arrays to the requested size */ - for (int i = 0; i < nbTraces; i++) { - fContexts.add(null); - fEvents.add(null); - } - } - - @Override - public void dispose() { - for (ITmfContext context : fContexts) { - context.dispose(); - } - super.dispose(); - } - - // ------------------------------------------------------------------------ - // Accessors - // ------------------------------------------------------------------------ - - /** - * Return how many traces this experiment context tracks the contexts of - * (a.k.a., the number of traces in the experiment). - * - * @return The number of traces in the experiment - */ - public int getNbTraces() { - return fContexts.size(); - } - - /** - * Get the current context of a specific trace - * - * @param traceIndex - * The index of the trace in the experiment - * @return The matching context object for that trace - */ - @Nullable - public ITmfContext getContext(int traceIndex) { - return fContexts.get(traceIndex); - } - - /** - * Set the context of a trace - * - * @param traceIndex - * The index of the trace in the experiment - * @param ctx - * The new context object for that trace - */ - public void setContext(int traceIndex, ITmfContext ctx) { - fContexts.set(traceIndex, ctx); - } - - /** - * Get the current event for a specific trace in the experiment. - * - * @param traceIndex - * The index of the trace in the experiment - * @return The event matching the trace/context - * - */ - @Nullable - public ITmfEvent getEvent(int traceIndex) { - return fEvents.get(traceIndex); - } - - /** - * Set the context's event for a specific trace - * - * @param traceIndex - * The index of the trace in the experiment - * @param event - * The event at the context in the trace - */ - public void setEvent(int traceIndex, ITmfEvent event) { - fEvents.set(traceIndex, event); - } - - /** - * Get the index of the trace that was last read (so the trace whose - * current context will match this experiment's). - * - * @return The index of the trace - */ - public int getLastTrace() { - return fLastTraceRead; - } - - /** - * Set the last trace read index - * - * @param newIndex - * The new value to assign - */ - public void setLastTrace(final int newIndex) { - fLastTraceRead = newIndex; - } - - // ------------------------------------------------------------------------ - // Object - // ------------------------------------------------------------------------ - - @Override - public int hashCode() { - int result = 17; - for (int i = 0; i < fContexts.size(); i++) { - result = 37 * result + fContexts.get(i).hashCode(); - } - return result; - } - - @Override - public boolean equals(final Object other) { - if (this == other) { - return true; - } - if (!super.equals(other)) { - return false; - } - if (!(other instanceof TmfExperimentContext)) { - return false; - } - final TmfExperimentContext o = (TmfExperimentContext) other; - boolean isEqual = true; - int i = 0; - while (isEqual && (i < fContexts.size())) { - isEqual &= fContexts.get(i).equals(o.fContexts.get(i)); - i++; - } - return isEqual; - } - - @Override - @SuppressWarnings("nls") - public String toString() { - StringBuilder sb = new StringBuilder("TmfExperimentContext [\n"); - sb.append("\tfLocation=" + getLocation() + ", fRank=" + getRank() + "\n"); - sb.append("\tfContexts=["); - for (int i = 0; i < fContexts.size(); i++) { - sb.append("(" + fContexts.get(i).getLocation() + "," + fContexts.get(i).getRank() + ((i < fContexts.size() - 1) ? ")," : ")]\n")); - } - sb.append("\tfEvents=["); - for (int i = 0; i < fEvents.size(); i++) { - ITmfEvent event = fEvents.get(i); - sb.append(((event != null) ? fEvents.get(i).getTimestamp() : "(null)") + ((i < fEvents.size() - 1) ? "," : "]\n")); - } - sb.append("\tfLastTraceRead=" + fLastTraceRead + "\n"); - sb.append("]"); - return sb.toString(); - } - -} diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/TmfExperimentLocation.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/TmfExperimentLocation.java deleted file mode 100644 index 1eb150b12d..0000000000 --- a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/TmfExperimentLocation.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * 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 ranks in experiment location - *******************************************************************************/ - -package org.eclipse.tracecompass.internal.tmf.core.trace; - -import java.nio.ByteBuffer; - -import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation; - - -/** - * The experiment location in TMF. - *

- * An experiment location is actually the set of locations of the traces it - * contains. By setting the individual traces to their corresponding locations, - * the experiment can be positioned to read the next chronological event. - *

- * It is the responsibility of the user the individual trace locations are valid - * and that they are matched to the correct trace. - * - * @version 1.0 - * @author Francois Chouinard - * - * @see TmfLocationArray - */ -public final class TmfExperimentLocation implements ITmfLocation { - - private final TmfLocationArray fLocation; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - /** - * The standard constructor - * - * @param locations the set of trace locations - */ - public TmfExperimentLocation(TmfLocationArray locations) { - fLocation = locations; - } - - /** - * The copy constructor - * - * @param location the other experiment location - */ - public TmfExperimentLocation(TmfExperimentLocation location) { - this(location.getLocationInfo()); - } - - // ------------------------------------------------------------------------ - // Object - // ------------------------------------------------------------------------ - - @Override - @SuppressWarnings("nls") - public String toString() { - StringBuilder result = new StringBuilder("TmfExperimentLocation ["); - result.append(fLocation.toString()); - result.append("]"); - return result.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((fLocation != null) ? fLocation.hashCode() : 0); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TmfExperimentLocation other = (TmfExperimentLocation) obj; - if (fLocation == null) { - if (other.fLocation != null) { - return false; - } - } else if (!fLocation.equals(other.fLocation)) { - return false; - } - return true; - } - - @Override - public TmfLocationArray getLocationInfo() { - return fLocation; - } - - @Override - public void serialize(ByteBuffer bufferOut) { - ITmfLocation[] locations = fLocation.getLocations(); - long[] ranks = fLocation.getRanks(); - for (int i = 0; i < locations.length; ++i) { - locations[i].serialize(bufferOut); - bufferOut.putLong(ranks[i]); - } - } -} diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/TmfLocationArray.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/TmfLocationArray.java deleted file mode 100644 index f67ea9ec8c..0000000000 --- a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/TmfLocationArray.java +++ /dev/null @@ -1,204 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2014 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: - * Patrick Tasse - Initial API and implementation - * Francois Chouinard - Put in shape for 1.0 - * Patrick Tasse - Updated for ranks in experiment location - *******************************************************************************/ - -package org.eclipse.tracecompass.internal.tmf.core.trace; - -import java.util.Arrays; - -import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation; - - -/** - * A convenience class to store trace location arrays. The main purpose is to - * provide an immutable and Comparable implementation for TmfExperimentLocation. - * - * @version 1.0 - * @author Patrick Tasse - */ -public final class TmfLocationArray implements Comparable { - - // ------------------------------------------------------------------------ - // Attributes - // ------------------------------------------------------------------------ - - private final ITmfLocation[] fLocations; - private final long [] fRanks; - - // ------------------------------------------------------------------------ - // Constructors - // ------------------------------------------------------------------------ - - /** - * The standard constructor. - * - * @param locations the locations - * @param ranks the ranks - */ - public TmfLocationArray(ITmfLocation[] locations, long[] ranks) { - fLocations = Arrays.copyOf(locations, locations.length); - fRanks = Arrays.copyOf(ranks, ranks.length); - } - - /** - * The update constructor. Copies the arrays and updates a single entry. - * - * @param locationArray the location array - * @param index the updated index - * @param location the updated location - * @param rank the updated rank - */ - public TmfLocationArray(TmfLocationArray locationArray, int index, ITmfLocation location, long rank) { - fLocations = Arrays.copyOf(locationArray.fLocations, locationArray.fLocations.length); - fLocations[index] = location; - fRanks = Arrays.copyOf(locationArray.fRanks, locationArray.fRanks.length); - fRanks[index] = rank; - } - - /** - * The empty constructor. - * - * @param size the number of elements in the array - */ - public TmfLocationArray(int size) { - fLocations = new ITmfLocation[size]; - fRanks = new long[size]; - } - - // ------------------------------------------------------------------------ - // Getters - // ------------------------------------------------------------------------ - - /** - * Returns the number of elements in this array. - * - * @return the number of elements in this array - */ - public int size() { - return fLocations.length; - } - - /** - * Get the locations inside this array. - * - * @return a copy of the locations array - */ - public ITmfLocation[] getLocations() { - return Arrays.copyOf(fLocations, fLocations.length); - } - - /** - * Get a specific location - * - * @param index the location element - * - * @return the specific location (possibly null) - */ - public ITmfLocation getLocation(int index) { - if (index >= 0 && index < fLocations.length) { - return fLocations[index]; - } - return null; - } - - /** - * Get the ranks inside this array. - * - * @return a copy of the ranks array - */ - public long[] getRanks() { - return Arrays.copyOf(fRanks, fRanks.length); - } - - /** - * Get a specific rank - * - * @param index the rank element - * - * @return the specific rank - */ - public long getRank(int index) { - if (index >= 0 && index < fRanks.length) { - return fRanks[index]; - } - return 0; - } - - // ------------------------------------------------------------------------ - // Comparable - // ------------------------------------------------------------------------ - - @Override - public int compareTo(TmfLocationArray o) { - for (int i = 0; i < fRanks.length; i++) { - long rank1 = fRanks[i]; - long rank2 = o.fRanks[i]; - if (rank1 < rank2) { - return -1; - } else if (rank1 > rank2) { - return 1; - } - } - return 0; - } - - // ------------------------------------------------------------------------ - // Object - // ------------------------------------------------------------------------ - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode(fLocations); - result = prime * result + Arrays.hashCode(fRanks); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - TmfLocationArray other = (TmfLocationArray) obj; - if (!Arrays.equals(fLocations, other.fLocations)) { - return false; - } - if (!Arrays.equals(fRanks, other.fRanks)) { - return false; - } - return true; - } - - @Override - @SuppressWarnings("nls") - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(getClass().getSimpleName() + " ["); - for (int i = 0; i < fLocations.length; i++) { - if (i > 0) { - sb.append(", "); - } - sb.append("[location=" + fLocations[i] + ",rank=" + fRanks[i] + "]"); - } - sb.append("]"); - return sb.toString(); - } - -} diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/experiment/TmfExperimentCheckpoint.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/experiment/TmfExperimentCheckpoint.java new file mode 100644 index 0000000000..568cbb25c4 --- /dev/null +++ b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/experiment/TmfExperimentCheckpoint.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * 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 + *******************************************************************************/ + +package org.eclipse.tracecompass.internal.tmf.core.trace.experiment; + +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; +import org.eclipse.tracecompass.tmf.core.trace.TmfContext; + +/** + * TmfExperimentCheckpoint + *

+ * TODO: Implement me. Please. + */ +public class TmfExperimentCheckpoint implements Comparable { + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + private final TmfTimestamp fTimestamp; + private final long[] fRanks; + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + /** + * @param ts the checkpoint timestamp + * @param contexts the corresponding set of trace contexts + */ + public TmfExperimentCheckpoint(final TmfTimestamp ts, final TmfContext[] contexts) { + fTimestamp = ts; + fRanks = new long[contexts.length]; + for (int i = 0; i < fRanks.length; i++) { + fRanks[i] = contexts[i].getRank(); + } + } + + // ------------------------------------------------------------------------ + // Accessors + // ------------------------------------------------------------------------ + + /** + * @return the checkpoint event timestamp + */ + public TmfTimestamp getTimestamp() { + return fTimestamp; + } + + /** + * @return the checkpoint event rank + */ + public long[] getRanks() { + return fRanks; + } + + // ------------------------------------------------------------------------ + // Object + // ------------------------------------------------------------------------ + + @Override + public int hashCode() { + int result = 37; + result = 17 * result + fTimestamp.hashCode(); + return result; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof TmfExperimentCheckpoint)) { + return false; + } + final TmfExperimentCheckpoint o = (TmfExperimentCheckpoint) other; + return fTimestamp.equals(o.fTimestamp); + } + + // ------------------------------------------------------------------------ + // Comparable + // ------------------------------------------------------------------------ + + @Override + public int compareTo(final TmfExperimentCheckpoint other) { + return fTimestamp.compareTo(other.fTimestamp); + } + +} diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/experiment/TmfExperimentContext.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/experiment/TmfExperimentContext.java new file mode 100644 index 0000000000..ed941a3455 --- /dev/null +++ b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/experiment/TmfExperimentContext.java @@ -0,0 +1,224 @@ +/******************************************************************************* + * 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 - Put in shape for 1.0 + * Patrick Tasse - Updated for removal of context clone + *******************************************************************************/ + +package org.eclipse.tracecompass.internal.tmf.core.trace.experiment; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; +import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; +import org.eclipse.tracecompass.tmf.core.trace.TmfContext; + +/** + * The experiment context in TMF. + *

+ * The experiment keeps track of the next event from each of its traces so it + * can pick the next one in chronological order. + *

+ * This implies that the "next" event from each trace has already been + * read and that we at least know its timestamp. + *

+ * The last trace refers to the trace from which the last event was "consumed" + * at the experiment level. + */ +public final class TmfExperimentContext extends TmfContext { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + + /** + * No last trace read indicator + */ + public static final int NO_TRACE = -1; + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + private final List fContexts; + private final List fEvents; + private int fLastTraceRead; + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + /** + * Standard constructor + * + * @param nbTraces + * The number of traces in the experiment + */ + public TmfExperimentContext(final int nbTraces) { + super(); + fLastTraceRead = NO_TRACE; + fContexts = new ArrayList<>(nbTraces); + fEvents = new ArrayList<>(nbTraces); + + + /* Initialize the arrays to the requested size */ + for (int i = 0; i < nbTraces; i++) { + fContexts.add(null); + fEvents.add(null); + } + } + + @Override + public void dispose() { + for (ITmfContext context : fContexts) { + context.dispose(); + } + super.dispose(); + } + + // ------------------------------------------------------------------------ + // Accessors + // ------------------------------------------------------------------------ + + /** + * Return how many traces this experiment context tracks the contexts of + * (a.k.a., the number of traces in the experiment). + * + * @return The number of traces in the experiment + */ + public int getNbTraces() { + return fContexts.size(); + } + + /** + * Get the current context of a specific trace + * + * @param traceIndex + * The index of the trace in the experiment + * @return The matching context object for that trace + */ + @Nullable + public ITmfContext getContext(int traceIndex) { + return fContexts.get(traceIndex); + } + + /** + * Set the context of a trace + * + * @param traceIndex + * The index of the trace in the experiment + * @param ctx + * The new context object for that trace + */ + public void setContext(int traceIndex, ITmfContext ctx) { + fContexts.set(traceIndex, ctx); + } + + /** + * Get the current event for a specific trace in the experiment. + * + * @param traceIndex + * The index of the trace in the experiment + * @return The event matching the trace/context + * + */ + @Nullable + public ITmfEvent getEvent(int traceIndex) { + return fEvents.get(traceIndex); + } + + /** + * Set the context's event for a specific trace + * + * @param traceIndex + * The index of the trace in the experiment + * @param event + * The event at the context in the trace + */ + public void setEvent(int traceIndex, ITmfEvent event) { + fEvents.set(traceIndex, event); + } + + /** + * Get the index of the trace that was last read (so the trace whose + * current context will match this experiment's). + * + * @return The index of the trace + */ + public int getLastTrace() { + return fLastTraceRead; + } + + /** + * Set the last trace read index + * + * @param newIndex + * The new value to assign + */ + public void setLastTrace(final int newIndex) { + fLastTraceRead = newIndex; + } + + // ------------------------------------------------------------------------ + // Object + // ------------------------------------------------------------------------ + + @Override + public int hashCode() { + int result = 17; + for (int i = 0; i < fContexts.size(); i++) { + result = 37 * result + fContexts.get(i).hashCode(); + } + return result; + } + + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!super.equals(other)) { + return false; + } + if (!(other instanceof TmfExperimentContext)) { + return false; + } + final TmfExperimentContext o = (TmfExperimentContext) other; + boolean isEqual = true; + int i = 0; + while (isEqual && (i < fContexts.size())) { + isEqual &= fContexts.get(i).equals(o.fContexts.get(i)); + i++; + } + return isEqual; + } + + @Override + @SuppressWarnings("nls") + public String toString() { + StringBuilder sb = new StringBuilder("TmfExperimentContext [\n"); + sb.append("\tfLocation=" + getLocation() + ", fRank=" + getRank() + "\n"); + sb.append("\tfContexts=["); + for (int i = 0; i < fContexts.size(); i++) { + sb.append("(" + fContexts.get(i).getLocation() + "," + fContexts.get(i).getRank() + ((i < fContexts.size() - 1) ? ")," : ")]\n")); + } + sb.append("\tfEvents=["); + for (int i = 0; i < fEvents.size(); i++) { + ITmfEvent event = fEvents.get(i); + sb.append(((event != null) ? fEvents.get(i).getTimestamp() : "(null)") + ((i < fEvents.size() - 1) ? "," : "]\n")); + } + sb.append("\tfLastTraceRead=" + fLastTraceRead + "\n"); + sb.append("]"); + return sb.toString(); + } + +} diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/experiment/TmfExperimentLocation.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/experiment/TmfExperimentLocation.java new file mode 100644 index 0000000000..fdaf8cff63 --- /dev/null +++ b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/experiment/TmfExperimentLocation.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * 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 ranks in experiment location + *******************************************************************************/ + +package org.eclipse.tracecompass.internal.tmf.core.trace.experiment; + +import java.nio.ByteBuffer; + +import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation; + + +/** + * The experiment location in TMF. + *

+ * An experiment location is actually the set of locations of the traces it + * contains. By setting the individual traces to their corresponding locations, + * the experiment can be positioned to read the next chronological event. + *

+ * It is the responsibility of the user the individual trace locations are valid + * and that they are matched to the correct trace. + * + * @version 1.0 + * @author Francois Chouinard + * + * @see TmfLocationArray + */ +public final class TmfExperimentLocation implements ITmfLocation { + + private final TmfLocationArray fLocation; + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + /** + * The standard constructor + * + * @param locations the set of trace locations + */ + public TmfExperimentLocation(TmfLocationArray locations) { + fLocation = locations; + } + + /** + * The copy constructor + * + * @param location the other experiment location + */ + public TmfExperimentLocation(TmfExperimentLocation location) { + this(location.getLocationInfo()); + } + + // ------------------------------------------------------------------------ + // Object + // ------------------------------------------------------------------------ + + @Override + @SuppressWarnings("nls") + public String toString() { + StringBuilder result = new StringBuilder("TmfExperimentLocation ["); + result.append(fLocation.toString()); + result.append("]"); + return result.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((fLocation != null) ? fLocation.hashCode() : 0); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final TmfExperimentLocation other = (TmfExperimentLocation) obj; + if (fLocation == null) { + if (other.fLocation != null) { + return false; + } + } else if (!fLocation.equals(other.fLocation)) { + return false; + } + return true; + } + + @Override + public TmfLocationArray getLocationInfo() { + return fLocation; + } + + @Override + public void serialize(ByteBuffer bufferOut) { + ITmfLocation[] locations = fLocation.getLocations(); + long[] ranks = fLocation.getRanks(); + for (int i = 0; i < locations.length; ++i) { + locations[i].serialize(bufferOut); + bufferOut.putLong(ranks[i]); + } + } +} diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/experiment/TmfLocationArray.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/experiment/TmfLocationArray.java new file mode 100644 index 0000000000..fa5428e6be --- /dev/null +++ b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/trace/experiment/TmfLocationArray.java @@ -0,0 +1,204 @@ +/******************************************************************************* + * Copyright (c) 2011, 2014 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: + * Patrick Tasse - Initial API and implementation + * Francois Chouinard - Put in shape for 1.0 + * Patrick Tasse - Updated for ranks in experiment location + *******************************************************************************/ + +package org.eclipse.tracecompass.internal.tmf.core.trace.experiment; + +import java.util.Arrays; + +import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation; + + +/** + * A convenience class to store trace location arrays. The main purpose is to + * provide an immutable and Comparable implementation for TmfExperimentLocation. + * + * @version 1.0 + * @author Patrick Tasse + */ +public final class TmfLocationArray implements Comparable { + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + private final ITmfLocation[] fLocations; + private final long [] fRanks; + + // ------------------------------------------------------------------------ + // Constructors + // ------------------------------------------------------------------------ + + /** + * The standard constructor. + * + * @param locations the locations + * @param ranks the ranks + */ + public TmfLocationArray(ITmfLocation[] locations, long[] ranks) { + fLocations = Arrays.copyOf(locations, locations.length); + fRanks = Arrays.copyOf(ranks, ranks.length); + } + + /** + * The update constructor. Copies the arrays and updates a single entry. + * + * @param locationArray the location array + * @param index the updated index + * @param location the updated location + * @param rank the updated rank + */ + public TmfLocationArray(TmfLocationArray locationArray, int index, ITmfLocation location, long rank) { + fLocations = Arrays.copyOf(locationArray.fLocations, locationArray.fLocations.length); + fLocations[index] = location; + fRanks = Arrays.copyOf(locationArray.fRanks, locationArray.fRanks.length); + fRanks[index] = rank; + } + + /** + * The empty constructor. + * + * @param size the number of elements in the array + */ + public TmfLocationArray(int size) { + fLocations = new ITmfLocation[size]; + fRanks = new long[size]; + } + + // ------------------------------------------------------------------------ + // Getters + // ------------------------------------------------------------------------ + + /** + * Returns the number of elements in this array. + * + * @return the number of elements in this array + */ + public int size() { + return fLocations.length; + } + + /** + * Get the locations inside this array. + * + * @return a copy of the locations array + */ + public ITmfLocation[] getLocations() { + return Arrays.copyOf(fLocations, fLocations.length); + } + + /** + * Get a specific location + * + * @param index the location element + * + * @return the specific location (possibly null) + */ + public ITmfLocation getLocation(int index) { + if (index >= 0 && index < fLocations.length) { + return fLocations[index]; + } + return null; + } + + /** + * Get the ranks inside this array. + * + * @return a copy of the ranks array + */ + public long[] getRanks() { + return Arrays.copyOf(fRanks, fRanks.length); + } + + /** + * Get a specific rank + * + * @param index the rank element + * + * @return the specific rank + */ + public long getRank(int index) { + if (index >= 0 && index < fRanks.length) { + return fRanks[index]; + } + return 0; + } + + // ------------------------------------------------------------------------ + // Comparable + // ------------------------------------------------------------------------ + + @Override + public int compareTo(TmfLocationArray o) { + for (int i = 0; i < fRanks.length; i++) { + long rank1 = fRanks[i]; + long rank2 = o.fRanks[i]; + if (rank1 < rank2) { + return -1; + } else if (rank1 > rank2) { + return 1; + } + } + return 0; + } + + // ------------------------------------------------------------------------ + // Object + // ------------------------------------------------------------------------ + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.hashCode(fLocations); + result = prime * result + Arrays.hashCode(fRanks); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + TmfLocationArray other = (TmfLocationArray) obj; + if (!Arrays.equals(fLocations, other.fLocations)) { + return false; + } + if (!Arrays.equals(fRanks, other.fRanks)) { + return false; + } + return true; + } + + @Override + @SuppressWarnings("nls") + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName() + " ["); + for (int i = 0; i < fLocations.length; i++) { + if (i > 0) { + sb.append(", "); + } + sb.append("[location=" + fLocations[i] + ",rank=" + fRanks[i] + "]"); + } + sb.append("]"); + return sb.toString(); + } + +} diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java index 8ce4dcc447..28f04a1306 100644 --- a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java +++ b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/TmfStateSystemAnalysisModule.java @@ -44,8 +44,8 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.ITmfTraceCompleteness; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; /** * Abstract analysis module to generate a state system. It is a base class that diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfExperiment.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfExperiment.java deleted file mode 100644 index 3b4423cf1f..0000000000 --- a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfExperiment.java +++ /dev/null @@ -1,709 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2014 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 - * 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 removal of context clone - * Patrick Tasse - Updated for ranks in experiment location - * Geneviève Bastien - Added support of experiment synchronization - * Added the initExperiment method and default constructor - *******************************************************************************/ - -package org.eclipse.tracecompass.tmf.core.trace; - -import java.io.File; -import java.nio.ByteBuffer; -import java.util.Arrays; - -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.MultiStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.tracecompass.internal.tmf.core.Activator; -import org.eclipse.tracecompass.internal.tmf.core.trace.TmfExperimentContext; -import org.eclipse.tracecompass.internal.tmf.core.trace.TmfExperimentLocation; -import org.eclipse.tracecompass.internal.tmf.core.trace.TmfLocationArray; -import org.eclipse.tracecompass.tmf.core.TmfCommonConstants; -import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; -import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; -import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest; -import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; -import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; -import org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal; -import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSynchronizedSignal; -import org.eclipse.tracecompass.tmf.core.synchronization.SynchronizationAlgorithm; -import org.eclipse.tracecompass.tmf.core.synchronization.SynchronizationManager; -import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; -import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; -import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfPersistentlyIndexable; -import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer; -import org.eclipse.tracecompass.tmf.core.trace.indexer.TmfBTreeTraceIndexer; -import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation; - -/** - * TmfExperiment presents a time-ordered, unified view of a set of ITmfTrace:s - * that are part of a tracing experiment. - * - * @version 1.0 - * @author Francois Chouinard - */ -public class TmfExperiment extends TmfTrace implements ITmfEventParser, ITmfPersistentlyIndexable { - - // ------------------------------------------------------------------------ - // Constants - // ------------------------------------------------------------------------ - - /** - * The file name of the Synchronization - * - * @since 3.0 - * @deprecated This file name shouldn't be used directly anymore. All - * synchronization files have been moved to a folder and you - * should use the {@link #getSynchronizationFolder(boolean)} - * method to return the path to this folder. - */ - @Deprecated - public static final String SYNCHRONIZATION_FILE_NAME = "synchronization.bin"; //$NON-NLS-1$ - - /** - * The name of the directory containing trace synchronization data. This - * directory typically will be preserved when traces are synchronized. - * Analysis involved in synchronization can put their supplementary files in - * there so they are not deleted when synchronized traces are copied. - */ - private static final String SYNCHRONIZATION_DIRECTORY = "sync_data"; //$NON-NLS-1$ - - /** - * The default index page size - */ - public static final int DEFAULT_INDEX_PAGE_SIZE = 5000; - - // ------------------------------------------------------------------------ - // Attributes - // ------------------------------------------------------------------------ - - /** - * The set of traces that constitute the experiment - */ - protected ITmfTrace[] fTraces; - - /** - * The set of traces that constitute the experiment - */ - private boolean fInitialized = false; - - - // ------------------------------------------------------------------------ - // Construction - // ------------------------------------------------------------------------ - - /** - * Default constructor. Should not be used directly, but is needed for - * extension points. - * - * @deprecated Do not call this directly (but do not remove it either!) - */ - @Deprecated - public TmfExperiment() { - super(); - } - - /** - * Constructor of an experiment, taking the type, path, traces, - * indexPageSize and 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. You can use - * {@link TmfExperiment#DEFAULT_INDEX_PAGE_SIZE} for a default - * value. - * @param resource - * The resource associated to the experiment. You can use 'null' - * for no resources (tests, etc.) - */ - public TmfExperiment(final Class type, - final String path, - final ITmfTrace[] traces, - final int indexPageSize, - final @Nullable IResource resource) { - initExperiment(type, path, traces, indexPageSize, resource); - } - - @Override - protected ITmfTraceIndexer createIndexer(int interval) { - if (getCheckpointSize() > 0) { - return new TmfBTreeTraceIndexer(this, interval); - } - return super.createIndexer(interval); - } - - /** - * Clears the experiment - */ - @Override - public synchronized void dispose() { - - // Clean up the index if applicable - if (getIndexer() != null) { - getIndexer().dispose(); - } - - if (fTraces != null) { - for (final ITmfTrace trace : fTraces) { - trace.dispose(); - } - fTraces = null; - } - super.dispose(); - } - - // ------------------------------------------------------------------------ - // ITmfTrace - Initializers - // ------------------------------------------------------------------------ - - @Override - public void initTrace(final IResource resource, final String path, final Class type) { - /* Do nothing for experiments */ - } - - /** - * Initialization of an experiment, taking the type, path, traces, - * indexPageSize and 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 resource - * the resource associated to the experiment - * @since 3.0 - */ - public void initExperiment(final Class type, - final String path, - final ITmfTrace[] traces, - final int indexPageSize, - final @Nullable IResource resource) { - - setCacheSize(indexPageSize); - setStreamingInterval(0); - setParser(this); - // traces have to be set before super.initialize() - fTraces = traces; - try { - super.initialize(resource, path, type); - } catch (TmfTraceException e) { - Activator.logError("Error initializing experiment", e); //$NON-NLS-1$ - } - - if (resource != null) { - this.synchronizeTraces(); - } - } - - /** - * @since 2.0 - */ - @Override - public IStatus validate(final IProject project, final String path) { - return Status.OK_STATUS; - } - - // ------------------------------------------------------------------------ - // Accessors - // ------------------------------------------------------------------------ - - /** - * Get the traces contained in this experiment. - * - * @return The array of contained traces - */ - public ITmfTrace[] getTraces() { - return fTraces; - } - - /** - * Returns the timestamp of the event at the requested index. If none, - * returns null. - * - * @param index - * the event index (rank) - * @return the corresponding event timestamp - * @since 2.0 - */ - public ITmfTimestamp getTimestamp(final int index) { - final ITmfContext context = seekEvent(index); - final ITmfEvent event = getNext(context); - context.dispose(); - return (event != null) ? event.getTimestamp() : null; - } - - // ------------------------------------------------------------------------ - // Request management - // ------------------------------------------------------------------------ - - /** - * @since 2.0 - */ - @Override - public synchronized ITmfContext armRequest(final ITmfEventRequest request) { - - // Make sure we have something to read from - if (fTraces == null) { - return null; - } - - if (!TmfTimestamp.BIG_BANG.equals(request.getRange().getStartTime()) - && request.getIndex() == 0) { - final ITmfContext context = seekEvent(request.getRange().getStartTime()); - request.setStartIndex((int) context.getRank()); - return context; - - } - - return seekEvent(request.getIndex()); - } - - // ------------------------------------------------------------------------ - // ITmfTrace trace positioning - // ------------------------------------------------------------------------ - - /** - * @since 3.0 - */ - @Override - public synchronized ITmfContext seekEvent(final ITmfLocation location) { - // Validate the location - if (location != null && !(location instanceof TmfExperimentLocation)) { - return null; // Throw an exception? - } - // Make sure we have something to read from - if (fTraces == null) { - return null; - } - - // Initialize the location array if necessary - TmfLocationArray locationArray = ((location == null) ? - new TmfLocationArray(fTraces.length) : - ((TmfExperimentLocation) location).getLocationInfo()); - - ITmfLocation[] locations = locationArray.getLocations(); - long[] ranks = locationArray.getRanks(); - - // Create and populate the context's traces contexts - final TmfExperimentContext context = new TmfExperimentContext(fTraces.length); - - // Position the traces - long rank = 0; - for (int i = 0; i < fTraces.length; i++) { - // Get the relevant trace attributes - final ITmfContext traceContext = fTraces[i].seekEvent(locations[i]); - context.setContext(i, traceContext); - traceContext.setRank(ranks[i]); - // update location after seek - locations[i] = traceContext.getLocation(); - context.setEvent(i, fTraces[i].getNext(traceContext)); - rank += ranks[i]; - } - - // Finalize context - context.setLocation(new TmfExperimentLocation(new TmfLocationArray(locations, ranks))); - context.setLastTrace(TmfExperimentContext.NO_TRACE); - context.setRank(rank); - - return context; - } - - // ------------------------------------------------------------------------ - // ITmfTrace - SeekEvent operations (returning a trace context) - // ------------------------------------------------------------------------ - - @Override - public ITmfContext seekEvent(final double ratio) { - final ITmfContext context = seekEvent(Math.round(ratio * getNbEvents())); - return context; - } - - /** - * @since 3.0 - */ - @Override - public double getLocationRatio(final ITmfLocation location) { - if (location instanceof TmfExperimentLocation) { - long rank = 0; - TmfLocationArray locationArray = ((TmfExperimentLocation) location).getLocationInfo(); - for (int i = 0; i < locationArray.size(); i++) { - rank += locationArray.getRank(i); - } - return (double) rank / getNbEvents(); - } - return 0.0; - } - - /** - * @since 3.0 - */ - @Override - public ITmfLocation getCurrentLocation() { - // never used - return null; - } - - // ------------------------------------------------------------------------ - // ITmfTrace trace positioning - // ------------------------------------------------------------------------ - - @Override - public synchronized ITmfEvent parseEvent(final ITmfContext context) { - final ITmfContext tmpContext = seekEvent(context.getLocation()); - final ITmfEvent event = getNext(tmpContext); - return event; - } - - @Override - public synchronized ITmfEvent getNext(ITmfContext context) { - - // Validate the context - if (!(context instanceof TmfExperimentContext)) { - return null; // Throw an exception? - } - - // Make sure that we have something to read from - if (fTraces == null) { - return null; - } - - TmfExperimentContext expContext = (TmfExperimentContext) context; - - // 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.getContext(lastTrace); - expContext.setEvent(lastTrace, fTraces[lastTrace].getNext(traceContext)); - expContext.setLastTrace(TmfExperimentContext.NO_TRACE); - } - - // Scan the candidate events and identify the "next" trace to read from - int trace = TmfExperimentContext.NO_TRACE; - ITmfTimestamp timestamp = TmfTimestamp.BIG_CRUNCH; - for (int i = 0; i < fTraces.length; i++) { - final ITmfEvent event = expContext.getEvent(i); - if (event != null && event.getTimestamp() != null) { - final ITmfTimestamp otherTS = event.getTimestamp(); - if (otherTS.compareTo(timestamp) < 0) { - trace = i; - timestamp = otherTS; - } - } - } - - ITmfEvent event = null; - if (trace != TmfExperimentContext.NO_TRACE) { - event = expContext.getEvent(trace); - if (event != null) { - updateAttributes(expContext, event.getTimestamp()); - expContext.increaseRank(); - expContext.setLastTrace(trace); - final ITmfContext traceContext = expContext.getContext(trace); - if (traceContext == null) { - throw new IllegalStateException(); - } - - // Update the experiment location - TmfLocationArray locationArray = new TmfLocationArray( - ((TmfExperimentLocation) expContext.getLocation()).getLocationInfo(), - trace, traceContext.getLocation(), traceContext.getRank()); - expContext.setLocation(new TmfExperimentLocation(locationArray)); - - processEvent(event); - } - } - - return event; - } - - /** - * @since 2.0 - */ - @Override - public ITmfTimestamp getInitialRangeOffset() { - if ((fTraces == null) || (fTraces.length == 0)) { - return super.getInitialRangeOffset(); - } - - ITmfTimestamp initTs = TmfTimestamp.BIG_CRUNCH; - for (int i = 0; i < fTraces.length; i++) { - ITmfTimestamp ts = fTraces[i].getInitialRangeOffset(); - if (ts.compareTo(initTs) < 0) { - initTs = ts; - } - } - return initTs; - } - - /** - * Get the path to the folder in the supplementary file where - * synchronization-related data can be kept so they are not deleted when the - * experiment is synchronized. Analysis involved in synchronization can put - * their supplementary files in there so they are preserved after - * synchronization. - * - * If the directory does not exist, it will be created. A return value of - * null means either the trace resource does not exist or - * supplementary resources cannot be kept. - * - * @param absolute - * If true, it returns the absolute path in the file - * system, including the supplementary file path. Otherwise, it - * returns only the directory name. - * @return The path to the folder where synchronization-related - * supplementary files can be kept or null if not - * available. - * @since 3.2 - */ - public String getSynchronizationFolder(boolean absolute) { - /* Set up the path to the synchronization file we'll use */ - IResource resource = this.getResource(); - String syncDirectory = null; - - try { - /* get the directory where the file will be stored. */ - if (resource != null) { - String fullDirectory = resource.getPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER); - /* Create the synchronization data directory if not present */ - if (fullDirectory != null) { - fullDirectory = fullDirectory + File.separator + SYNCHRONIZATION_DIRECTORY; - File syncDir = new File(fullDirectory); - syncDir.mkdirs(); - } - if (absolute) { - syncDirectory = fullDirectory; - } else { - syncDirectory = SYNCHRONIZATION_DIRECTORY; - } - } - } catch (CoreException e) { - return null; - } - - return syncDirectory; - } - - /** - * Synchronizes the traces of an experiment. By default it only tries to - * read a synchronization file if it exists - * - * @return The synchronization object - * @since 3.0 - */ - public synchronized SynchronizationAlgorithm synchronizeTraces() { - 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 - * @since 3.0 - */ - public synchronized SynchronizationAlgorithm synchronizeTraces(boolean doSync) { - - String syncDirectory = getSynchronizationFolder(true); - - final File syncFile = (syncDirectory != null) ? new File(syncDirectory + File.separator + SYNCHRONIZATION_FILE_NAME) : null; - - final SynchronizationAlgorithm syncAlgo = SynchronizationManager.synchronizeTraces(syncFile, Arrays.asList(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() { - return "[TmfExperiment (" + getName() + ")]"; - } - - // ------------------------------------------------------------------------ - // Streaming support - // ------------------------------------------------------------------------ - - private synchronized void initializeStreamingMonitor() { - - if (fInitialized) { - return; - } - fInitialized = true; - - if (getStreamingInterval() == 0) { - final ITmfContext context = seekEvent(0); - final ITmfEvent event = getNext(context); - context.dispose(); - if (event == null) { - return; - } - final TmfTimeRange timeRange = new TmfTimeRange(event.getTimestamp(), TmfTimestamp.BIG_CRUNCH); - final TmfTraceRangeUpdatedSignal signal = new TmfTraceRangeUpdatedSignal(this, this, timeRange); - - // Broadcast in separate thread to prevent deadlock - new Thread() { - @Override - public void run() { - broadcast(signal); - } - }.start(); - return; - } - - final Thread thread = new Thread("Streaming Monitor for experiment " + getName()) { //$NON-NLS-1$ - private ITmfTimestamp safeTimestamp = null; - private ITmfTimestamp lastSafeTimestamp = null; - private TmfTimeRange timeRange = null; - - @Override - public void run() { - while (!executorIsShutdown()) { - if (!getIndexer().isIndexing()) { - ITmfTimestamp startTimestamp = TmfTimestamp.BIG_CRUNCH; - ITmfTimestamp endTimestamp = TmfTimestamp.BIG_BANG; - for (final ITmfTrace trace : fTraces) { - if (trace.getStartTime().compareTo(startTimestamp) < 0) { - startTimestamp = trace.getStartTime(); - } - if (trace.getStreamingInterval() != 0 && trace.getEndTime().compareTo(endTimestamp) > 0) { - endTimestamp = trace.getEndTime(); - } - } - if (safeTimestamp != null && (lastSafeTimestamp == null || safeTimestamp.compareTo(lastSafeTimestamp) > 0)) { - timeRange = new TmfTimeRange(startTimestamp, safeTimestamp); - lastSafeTimestamp = safeTimestamp; - } else { - timeRange = null; - } - safeTimestamp = endTimestamp; - if (timeRange != null) { - final TmfTraceRangeUpdatedSignal signal = - new TmfTraceRangeUpdatedSignal(TmfExperiment.this, TmfExperiment.this, timeRange); - broadcast(signal); - } - } - try { - Thread.sleep(getStreamingInterval()); - } catch (final InterruptedException e) { - e.printStackTrace(); - } - } - } - }; - thread.start(); - } - - @Override - public long getStreamingInterval() { - long interval = 0; - for (final ITmfTrace trace : fTraces) { - interval = Math.max(interval, trace.getStreamingInterval()); - } - return interval; - } - - // ------------------------------------------------------------------------ - // Signal handlers - // ------------------------------------------------------------------------ - - @Override - @TmfSignalHandler - public void traceOpened(TmfTraceOpenedSignal signal) { - if (signal.getTrace() == this) { - initializeStreamingMonitor(); - - /* Initialize the analysis */ - MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, null, null); - status.add(executeAnalysis()); - if (!status.isOK()) { - Activator.log(status); - } - TmfTraceManager.refreshSupplementaryFiles(this); - } - } - - /** - * @since 3.0 - */ - @Override - public synchronized int getCheckpointSize() { - int totalCheckpointSize = 0; - try { - if (fTraces != null) { - for (final ITmfTrace trace : fTraces) { - if (!(trace instanceof ITmfPersistentlyIndexable)) { - return 0; - } - - ITmfPersistentlyIndexable persistableIndexTrace = (ITmfPersistentlyIndexable) trace; - int currentTraceCheckpointSize = persistableIndexTrace.getCheckpointSize(); - if (currentTraceCheckpointSize <= 0) { - return 0; - } - totalCheckpointSize += currentTraceCheckpointSize; - // each entry in the TmfLocationArray has a rank in addition - // of the location - totalCheckpointSize += 8; - } - } - } catch (UnsupportedOperationException e) { - return 0; - } - - return totalCheckpointSize; - } - - /** - * @since 3.0 - */ - @Override - public ITmfLocation restoreLocation(ByteBuffer bufferIn) { - ITmfLocation[] locations = new ITmfLocation[fTraces.length]; - long[] ranks = new long[fTraces.length]; - for (int i = 0; i < fTraces.length; ++i) { - final ITmfTrace trace = fTraces[i]; - locations[i] = ((ITmfPersistentlyIndexable) trace).restoreLocation(bufferIn); - ranks[i] = bufferIn.getLong(); - } - TmfLocationArray arr = new TmfLocationArray(locations, ranks); - TmfExperimentLocation l = new TmfExperimentLocation(arr); - return l; - } - -} diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java index da3d90589d..e342b80661 100644 --- a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java +++ b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceManager.java @@ -44,6 +44,7 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; /** * Central trace manager for TMF. It tracks the currently opened traces and diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/experiment/TmfExperiment.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/experiment/TmfExperiment.java new file mode 100644 index 0000000000..29bbe6d76e --- /dev/null +++ b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/experiment/TmfExperiment.java @@ -0,0 +1,714 @@ +/******************************************************************************* + * Copyright (c) 2009, 2014 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 + * 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 removal of context clone + * Patrick Tasse - Updated for ranks in experiment location + * Geneviève Bastien - Added support of experiment synchronization + * Added the initExperiment method and default constructor + *******************************************************************************/ + +package org.eclipse.tracecompass.tmf.core.trace.experiment; + +import java.io.File; +import java.nio.ByteBuffer; +import java.util.Arrays; + +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.MultiStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.tracecompass.internal.tmf.core.Activator; +import org.eclipse.tracecompass.internal.tmf.core.trace.experiment.TmfExperimentContext; +import org.eclipse.tracecompass.internal.tmf.core.trace.experiment.TmfExperimentLocation; +import org.eclipse.tracecompass.internal.tmf.core.trace.experiment.TmfLocationArray; +import org.eclipse.tracecompass.tmf.core.TmfCommonConstants; +import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; +import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; +import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest; +import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; +import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; +import org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal; +import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSynchronizedSignal; +import org.eclipse.tracecompass.tmf.core.synchronization.SynchronizationAlgorithm; +import org.eclipse.tracecompass.tmf.core.synchronization.SynchronizationManager; +import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; +import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; +import org.eclipse.tracecompass.tmf.core.trace.ITmfEventParser; +import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; +import org.eclipse.tracecompass.tmf.core.trace.TmfTrace; +import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; +import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfPersistentlyIndexable; +import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer; +import org.eclipse.tracecompass.tmf.core.trace.indexer.TmfBTreeTraceIndexer; +import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation; + +/** + * TmfExperiment presents a time-ordered, unified view of a set of ITmfTrace:s + * that are part of a tracing experiment. + * + * @version 1.0 + * @author Francois Chouinard + */ +public class TmfExperiment extends TmfTrace implements ITmfEventParser, ITmfPersistentlyIndexable { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + + /** + * The file name of the Synchronization + * + * @since 3.0 + * @deprecated This file name shouldn't be used directly anymore. All + * synchronization files have been moved to a folder and you + * should use the {@link #getSynchronizationFolder(boolean)} + * method to return the path to this folder. + */ + @Deprecated + public static final String SYNCHRONIZATION_FILE_NAME = "synchronization.bin"; //$NON-NLS-1$ + + /** + * The name of the directory containing trace synchronization data. This + * directory typically will be preserved when traces are synchronized. + * Analysis involved in synchronization can put their supplementary files in + * there so they are not deleted when synchronized traces are copied. + */ + private static final String SYNCHRONIZATION_DIRECTORY = "sync_data"; //$NON-NLS-1$ + + /** + * The default index page size + */ + public static final int DEFAULT_INDEX_PAGE_SIZE = 5000; + + // ------------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------------ + + /** + * The set of traces that constitute the experiment + */ + protected ITmfTrace[] fTraces; + + /** + * The set of traces that constitute the experiment + */ + private boolean fInitialized = false; + + + // ------------------------------------------------------------------------ + // Construction + // ------------------------------------------------------------------------ + + /** + * Default constructor. Should not be used directly, but is needed for + * extension points. + * + * @deprecated Do not call this directly (but do not remove it either!) + */ + @Deprecated + public TmfExperiment() { + super(); + } + + /** + * Constructor of an experiment, taking the type, path, traces, + * indexPageSize and 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. You can use + * {@link TmfExperiment#DEFAULT_INDEX_PAGE_SIZE} for a default + * value. + * @param resource + * The resource associated to the experiment. You can use 'null' + * for no resources (tests, etc.) + */ + public TmfExperiment(final Class type, + final String path, + final ITmfTrace[] traces, + final int indexPageSize, + final @Nullable IResource resource) { + initExperiment(type, path, traces, indexPageSize, resource); + } + + @Override + protected ITmfTraceIndexer createIndexer(int interval) { + if (getCheckpointSize() > 0) { + return new TmfBTreeTraceIndexer(this, interval); + } + return super.createIndexer(interval); + } + + /** + * Clears the experiment + */ + @Override + public synchronized void dispose() { + + // Clean up the index if applicable + if (getIndexer() != null) { + getIndexer().dispose(); + } + + if (fTraces != null) { + for (final ITmfTrace trace : fTraces) { + trace.dispose(); + } + fTraces = null; + } + super.dispose(); + } + + // ------------------------------------------------------------------------ + // ITmfTrace - Initializers + // ------------------------------------------------------------------------ + + @Override + public void initTrace(final IResource resource, final String path, final Class type) { + /* Do nothing for experiments */ + } + + /** + * Initialization of an experiment, taking the type, path, traces, + * indexPageSize and 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 resource + * the resource associated to the experiment + * @since 3.0 + */ + public void initExperiment(final Class type, + final String path, + final ITmfTrace[] traces, + final int indexPageSize, + final @Nullable IResource resource) { + + setCacheSize(indexPageSize); + setStreamingInterval(0); + setParser(this); + // traces have to be set before super.initialize() + fTraces = traces; + try { + super.initialize(resource, path, type); + } catch (TmfTraceException e) { + Activator.logError("Error initializing experiment", e); //$NON-NLS-1$ + } + + if (resource != null) { + this.synchronizeTraces(); + } + } + + /** + * @since 2.0 + */ + @Override + public IStatus validate(final IProject project, final String path) { + return Status.OK_STATUS; + } + + // ------------------------------------------------------------------------ + // Accessors + // ------------------------------------------------------------------------ + + /** + * Get the traces contained in this experiment. + * + * @return The array of contained traces + */ + public ITmfTrace[] getTraces() { + return fTraces; + } + + /** + * Returns the timestamp of the event at the requested index. If none, + * returns null. + * + * @param index + * the event index (rank) + * @return the corresponding event timestamp + * @since 2.0 + */ + public ITmfTimestamp getTimestamp(final int index) { + final ITmfContext context = seekEvent(index); + final ITmfEvent event = getNext(context); + context.dispose(); + return (event != null) ? event.getTimestamp() : null; + } + + // ------------------------------------------------------------------------ + // Request management + // ------------------------------------------------------------------------ + + /** + * @since 2.0 + */ + @Override + public synchronized ITmfContext armRequest(final ITmfEventRequest request) { + + // Make sure we have something to read from + if (fTraces == null) { + return null; + } + + if (!TmfTimestamp.BIG_BANG.equals(request.getRange().getStartTime()) + && request.getIndex() == 0) { + final ITmfContext context = seekEvent(request.getRange().getStartTime()); + request.setStartIndex((int) context.getRank()); + return context; + + } + + return seekEvent(request.getIndex()); + } + + // ------------------------------------------------------------------------ + // ITmfTrace trace positioning + // ------------------------------------------------------------------------ + + /** + * @since 3.0 + */ + @Override + public synchronized ITmfContext seekEvent(final ITmfLocation location) { + // Validate the location + if (location != null && !(location instanceof TmfExperimentLocation)) { + return null; // Throw an exception? + } + // Make sure we have something to read from + if (fTraces == null) { + return null; + } + + // Initialize the location array if necessary + TmfLocationArray locationArray = ((location == null) ? + new TmfLocationArray(fTraces.length) : + ((TmfExperimentLocation) location).getLocationInfo()); + + ITmfLocation[] locations = locationArray.getLocations(); + long[] ranks = locationArray.getRanks(); + + // Create and populate the context's traces contexts + final TmfExperimentContext context = new TmfExperimentContext(fTraces.length); + + // Position the traces + long rank = 0; + for (int i = 0; i < fTraces.length; i++) { + // Get the relevant trace attributes + final ITmfContext traceContext = fTraces[i].seekEvent(locations[i]); + context.setContext(i, traceContext); + traceContext.setRank(ranks[i]); + // update location after seek + locations[i] = traceContext.getLocation(); + context.setEvent(i, fTraces[i].getNext(traceContext)); + rank += ranks[i]; + } + + // Finalize context + context.setLocation(new TmfExperimentLocation(new TmfLocationArray(locations, ranks))); + context.setLastTrace(TmfExperimentContext.NO_TRACE); + context.setRank(rank); + + return context; + } + + // ------------------------------------------------------------------------ + // ITmfTrace - SeekEvent operations (returning a trace context) + // ------------------------------------------------------------------------ + + @Override + public ITmfContext seekEvent(final double ratio) { + final ITmfContext context = seekEvent(Math.round(ratio * getNbEvents())); + return context; + } + + /** + * @since 3.0 + */ + @Override + public double getLocationRatio(final ITmfLocation location) { + if (location instanceof TmfExperimentLocation) { + long rank = 0; + TmfLocationArray locationArray = ((TmfExperimentLocation) location).getLocationInfo(); + for (int i = 0; i < locationArray.size(); i++) { + rank += locationArray.getRank(i); + } + return (double) rank / getNbEvents(); + } + return 0.0; + } + + /** + * @since 3.0 + */ + @Override + public ITmfLocation getCurrentLocation() { + // never used + return null; + } + + // ------------------------------------------------------------------------ + // ITmfTrace trace positioning + // ------------------------------------------------------------------------ + + @Override + public synchronized ITmfEvent parseEvent(final ITmfContext context) { + final ITmfContext tmpContext = seekEvent(context.getLocation()); + final ITmfEvent event = getNext(tmpContext); + return event; + } + + @Override + public synchronized ITmfEvent getNext(ITmfContext context) { + + // Validate the context + if (!(context instanceof TmfExperimentContext)) { + return null; // Throw an exception? + } + + // Make sure that we have something to read from + if (fTraces == null) { + return null; + } + + TmfExperimentContext expContext = (TmfExperimentContext) context; + + // 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.getContext(lastTrace); + expContext.setEvent(lastTrace, fTraces[lastTrace].getNext(traceContext)); + expContext.setLastTrace(TmfExperimentContext.NO_TRACE); + } + + // Scan the candidate events and identify the "next" trace to read from + int trace = TmfExperimentContext.NO_TRACE; + ITmfTimestamp timestamp = TmfTimestamp.BIG_CRUNCH; + for (int i = 0; i < fTraces.length; i++) { + final ITmfEvent event = expContext.getEvent(i); + if (event != null && event.getTimestamp() != null) { + final ITmfTimestamp otherTS = event.getTimestamp(); + if (otherTS.compareTo(timestamp) < 0) { + trace = i; + timestamp = otherTS; + } + } + } + + ITmfEvent event = null; + if (trace != TmfExperimentContext.NO_TRACE) { + event = expContext.getEvent(trace); + if (event != null) { + updateAttributes(expContext, event.getTimestamp()); + expContext.increaseRank(); + expContext.setLastTrace(trace); + final ITmfContext traceContext = expContext.getContext(trace); + if (traceContext == null) { + throw new IllegalStateException(); + } + + // Update the experiment location + TmfLocationArray locationArray = new TmfLocationArray( + ((TmfExperimentLocation) expContext.getLocation()).getLocationInfo(), + trace, traceContext.getLocation(), traceContext.getRank()); + expContext.setLocation(new TmfExperimentLocation(locationArray)); + + processEvent(event); + } + } + + return event; + } + + /** + * @since 2.0 + */ + @Override + public ITmfTimestamp getInitialRangeOffset() { + if ((fTraces == null) || (fTraces.length == 0)) { + return super.getInitialRangeOffset(); + } + + ITmfTimestamp initTs = TmfTimestamp.BIG_CRUNCH; + for (int i = 0; i < fTraces.length; i++) { + ITmfTimestamp ts = fTraces[i].getInitialRangeOffset(); + if (ts.compareTo(initTs) < 0) { + initTs = ts; + } + } + return initTs; + } + + /** + * Get the path to the folder in the supplementary file where + * synchronization-related data can be kept so they are not deleted when the + * experiment is synchronized. Analysis involved in synchronization can put + * their supplementary files in there so they are preserved after + * synchronization. + * + * If the directory does not exist, it will be created. A return value of + * null means either the trace resource does not exist or + * supplementary resources cannot be kept. + * + * @param absolute + * If true, it returns the absolute path in the file + * system, including the supplementary file path. Otherwise, it + * returns only the directory name. + * @return The path to the folder where synchronization-related + * supplementary files can be kept or null if not + * available. + * @since 3.2 + */ + public String getSynchronizationFolder(boolean absolute) { + /* Set up the path to the synchronization file we'll use */ + IResource resource = this.getResource(); + String syncDirectory = null; + + try { + /* get the directory where the file will be stored. */ + if (resource != null) { + String fullDirectory = resource.getPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER); + /* Create the synchronization data directory if not present */ + if (fullDirectory != null) { + fullDirectory = fullDirectory + File.separator + SYNCHRONIZATION_DIRECTORY; + File syncDir = new File(fullDirectory); + syncDir.mkdirs(); + } + if (absolute) { + syncDirectory = fullDirectory; + } else { + syncDirectory = SYNCHRONIZATION_DIRECTORY; + } + } + } catch (CoreException e) { + return null; + } + + return syncDirectory; + } + + /** + * Synchronizes the traces of an experiment. By default it only tries to + * read a synchronization file if it exists + * + * @return The synchronization object + * @since 3.0 + */ + public synchronized SynchronizationAlgorithm synchronizeTraces() { + 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 + * @since 3.0 + */ + public synchronized SynchronizationAlgorithm synchronizeTraces(boolean doSync) { + + String syncDirectory = getSynchronizationFolder(true); + + final File syncFile = (syncDirectory != null) ? new File(syncDirectory + File.separator + SYNCHRONIZATION_FILE_NAME) : null; + + final SynchronizationAlgorithm syncAlgo = SynchronizationManager.synchronizeTraces(syncFile, Arrays.asList(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() { + return "[TmfExperiment (" + getName() + ")]"; + } + + // ------------------------------------------------------------------------ + // Streaming support + // ------------------------------------------------------------------------ + + private synchronized void initializeStreamingMonitor() { + + if (fInitialized) { + return; + } + fInitialized = true; + + if (getStreamingInterval() == 0) { + final ITmfContext context = seekEvent(0); + final ITmfEvent event = getNext(context); + context.dispose(); + if (event == null) { + return; + } + final TmfTimeRange timeRange = new TmfTimeRange(event.getTimestamp(), TmfTimestamp.BIG_CRUNCH); + final TmfTraceRangeUpdatedSignal signal = new TmfTraceRangeUpdatedSignal(this, this, timeRange); + + // Broadcast in separate thread to prevent deadlock + new Thread() { + @Override + public void run() { + broadcast(signal); + } + }.start(); + return; + } + + final Thread thread = new Thread("Streaming Monitor for experiment " + getName()) { //$NON-NLS-1$ + private ITmfTimestamp safeTimestamp = null; + private ITmfTimestamp lastSafeTimestamp = null; + private TmfTimeRange timeRange = null; + + @Override + public void run() { + while (!executorIsShutdown()) { + if (!getIndexer().isIndexing()) { + ITmfTimestamp startTimestamp = TmfTimestamp.BIG_CRUNCH; + ITmfTimestamp endTimestamp = TmfTimestamp.BIG_BANG; + for (final ITmfTrace trace : fTraces) { + if (trace.getStartTime().compareTo(startTimestamp) < 0) { + startTimestamp = trace.getStartTime(); + } + if (trace.getStreamingInterval() != 0 && trace.getEndTime().compareTo(endTimestamp) > 0) { + endTimestamp = trace.getEndTime(); + } + } + if (safeTimestamp != null && (lastSafeTimestamp == null || safeTimestamp.compareTo(lastSafeTimestamp) > 0)) { + timeRange = new TmfTimeRange(startTimestamp, safeTimestamp); + lastSafeTimestamp = safeTimestamp; + } else { + timeRange = null; + } + safeTimestamp = endTimestamp; + if (timeRange != null) { + final TmfTraceRangeUpdatedSignal signal = + new TmfTraceRangeUpdatedSignal(TmfExperiment.this, TmfExperiment.this, timeRange); + broadcast(signal); + } + } + try { + Thread.sleep(getStreamingInterval()); + } catch (final InterruptedException e) { + e.printStackTrace(); + } + } + } + }; + thread.start(); + } + + @Override + public long getStreamingInterval() { + long interval = 0; + for (final ITmfTrace trace : fTraces) { + interval = Math.max(interval, trace.getStreamingInterval()); + } + return interval; + } + + // ------------------------------------------------------------------------ + // Signal handlers + // ------------------------------------------------------------------------ + + @Override + @TmfSignalHandler + public void traceOpened(TmfTraceOpenedSignal signal) { + if (signal.getTrace() == this) { + initializeStreamingMonitor(); + + /* Initialize the analysis */ + MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, null, null); + status.add(executeAnalysis()); + if (!status.isOK()) { + Activator.log(status); + } + TmfTraceManager.refreshSupplementaryFiles(this); + } + } + + /** + * @since 3.0 + */ + @Override + public synchronized int getCheckpointSize() { + int totalCheckpointSize = 0; + try { + if (fTraces != null) { + for (final ITmfTrace trace : fTraces) { + if (!(trace instanceof ITmfPersistentlyIndexable)) { + return 0; + } + + ITmfPersistentlyIndexable persistableIndexTrace = (ITmfPersistentlyIndexable) trace; + int currentTraceCheckpointSize = persistableIndexTrace.getCheckpointSize(); + if (currentTraceCheckpointSize <= 0) { + return 0; + } + totalCheckpointSize += currentTraceCheckpointSize; + // each entry in the TmfLocationArray has a rank in addition + // of the location + totalCheckpointSize += 8; + } + } + } catch (UnsupportedOperationException e) { + return 0; + } + + return totalCheckpointSize; + } + + /** + * @since 3.0 + */ + @Override + public ITmfLocation restoreLocation(ByteBuffer bufferIn) { + ITmfLocation[] locations = new ITmfLocation[fTraces.length]; + long[] ranks = new long[fTraces.length]; + for (int i = 0; i < fTraces.length; ++i) { + final ITmfTrace trace = fTraces[i]; + locations[i] = ((ITmfPersistentlyIndexable) trace).restoreLocation(bufferIn); + ranks[i] = bufferIn.getLong(); + } + TmfLocationArray arr = new TmfLocationArray(locations, ranks); + TmfExperimentLocation l = new TmfExperimentLocation(arr); + return l; + } + +} diff --git a/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/headless/RequestBenchmark.java b/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/headless/RequestBenchmark.java index 7703bac081..758f3e3dc0 100644 --- a/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/headless/RequestBenchmark.java +++ b/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/headless/RequestBenchmark.java @@ -19,7 +19,7 @@ import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent; import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; diff --git a/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/tracemanager/TmfTraceManagerTest.java b/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/tracemanager/TmfTraceManagerTest.java index 752e24107b..8859b4ef61 100644 --- a/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/tracemanager/TmfTraceManagerTest.java +++ b/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/temp/tracemanager/TmfTraceManagerTest.java @@ -33,8 +33,8 @@ import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace; import org.junit.After; import org.junit.AfterClass; diff --git a/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/analysis/StreamListAnalysis.java b/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/analysis/StreamListAnalysis.java index a0c3fa7c36..3dac79ada9 100644 --- a/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/analysis/StreamListAnalysis.java +++ b/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/analysis/StreamListAnalysis.java @@ -29,7 +29,7 @@ import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest; import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; /** * A pcap-specific analysis that parse an entire trace to find all the streams. diff --git a/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/project/model/TraceAndExperimentTypeTest.java b/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/project/model/TraceAndExperimentTypeTest.java index 20a6020a10..183879349f 100644 --- a/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/project/model/TraceAndExperimentTypeTest.java +++ b/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/project/model/TraceAndExperimentTypeTest.java @@ -25,7 +25,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.tracecompass.tmf.core.TmfCommonConstants; import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfExperimentStub; import org.eclipse.tracecompass.tmf.ui.editors.TmfEventsEditor; import org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement; diff --git a/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/Uml2SDTestFacility.java b/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/Uml2SDTestFacility.java index 4bd2b83f2e..261ff2bcac 100644 --- a/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/Uml2SDTestFacility.java +++ b/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/views/uml2sd/loader/Uml2SDTestFacility.java @@ -29,7 +29,7 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal; import org.eclipse.tracecompass.tmf.core.trace.ITmfEventParser; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer; import org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer; import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub; diff --git a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/SynchronizeTracesHandler.java b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/SynchronizeTracesHandler.java index 013e43eb2a..13706e7243 100644 --- a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/SynchronizeTracesHandler.java +++ b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/handlers/SynchronizeTracesHandler.java @@ -32,8 +32,8 @@ import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; import org.eclipse.tracecompass.tmf.core.synchronization.SynchronizationAlgorithm; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement; import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement; import org.eclipse.tracecompass.tmf.ui.project.model.TraceUtils; diff --git a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/model/TmfEditorLinkHelper.java b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/model/TmfEditorLinkHelper.java index 94a517403c..03fd15f392 100644 --- a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/model/TmfEditorLinkHelper.java +++ b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/model/TmfEditorLinkHelper.java @@ -16,8 +16,8 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.tracecompass.tmf.core.TmfCommonConstants; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; import org.eclipse.tracecompass.tmf.core.trace.TmfTrace; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement; import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectElement; import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry; diff --git a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/editors/TmfEventsEditor.java b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/editors/TmfEventsEditor.java index 75300b2576..3f8e289fc1 100644 --- a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/editors/TmfEventsEditor.java +++ b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/editors/TmfEventsEditor.java @@ -49,8 +49,8 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal; import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; import org.eclipse.tracecompass.tmf.core.trace.TmfTrace; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.ui.project.model.Messages; import org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement; import org.eclipse.tracecompass.tmf.ui.project.model.TmfOpenTraceHelper; diff --git a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfCommonProjectElement.java b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfCommonProjectElement.java index d13039780f..1b797a5412 100644 --- a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfCommonProjectElement.java +++ b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfCommonProjectElement.java @@ -43,9 +43,9 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; import org.eclipse.tracecompass.tmf.core.trace.TmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.ui.IEditorReference; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; diff --git a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfExperimentElement.java b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfExperimentElement.java index 4944a8040e..a744202c08 100644 --- a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfExperimentElement.java +++ b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfExperimentElement.java @@ -41,7 +41,7 @@ import org.eclipse.tracecompass.internal.tmf.ui.Activator; import org.eclipse.tracecompass.tmf.core.TmfCommonConstants; import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType; import org.eclipse.tracecompass.tmf.core.project.model.TraceTypeHelper; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.ui.editors.TmfEventsEditor; import org.eclipse.tracecompass.tmf.ui.properties.ReadOnlyTextPropertyDescriptor; import org.eclipse.ui.views.properties.IPropertyDescriptor; diff --git a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfOpenTraceHelper.java b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfOpenTraceHelper.java index 1e78fab27d..992c297d0b 100644 --- a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfOpenTraceHelper.java +++ b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfOpenTraceHelper.java @@ -41,7 +41,7 @@ import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceImportException; import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType; import org.eclipse.tracecompass.tmf.core.project.model.TraceTypeHelper; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.ui.editors.TmfEditorInput; import org.eclipse.tracecompass.tmf.ui.editors.TmfEventsEditor; import org.eclipse.ui.IEditorInput; diff --git a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/statistics/TmfStatisticsViewer.java b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/statistics/TmfStatisticsViewer.java index daba98bc41..75f0772140 100644 --- a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/statistics/TmfStatisticsViewer.java +++ b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/statistics/TmfStatisticsViewer.java @@ -48,8 +48,8 @@ import org.eclipse.tracecompass.tmf.core.statistics.TmfStatisticsModule; import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.ui.TmfUiRefreshHandler; import org.eclipse.tracecompass.tmf.ui.viewers.TmfViewer; import org.eclipse.tracecompass.tmf.ui.viewers.statistics.model.TmfBaseColumnData; diff --git a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/synchronization/TmfSynchronizationView.java b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/synchronization/TmfSynchronizationView.java index 8021e1dabb..324908432b 100644 --- a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/synchronization/TmfSynchronizationView.java +++ b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/synchronization/TmfSynchronizationView.java @@ -25,8 +25,8 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSynchronizedSignal; import org.eclipse.tracecompass.tmf.core.synchronization.SynchronizationAlgorithm; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; -import org.eclipse.tracecompass.tmf.core.trace.TmfExperiment; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; +import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; import org.eclipse.tracecompass.tmf.ui.views.TmfView; /**