From: Matthew Khouzam Date: Sat, 30 Jan 2016 02:51:58 +0000 (-0500) Subject: analysis: introduce ISegmentStoreProvider X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=0f769d2b87b036038d54e59139901e071757a05c;p=deliverable%2Ftracecompass.git analysis: introduce ISegmentStoreProvider This is an interface extraction from AbstractSegmentStoreAnalysisModule that reduces the coupling. Now analyses no longer need to be dependent on events and event requests to generate segments. This open the door for segments being generated from other sources, such as, but not limited to: * State systems * Other segment stores * Environment variables * Aspects * Concepts * Flat data files. * ... Change-Id: If95f97d6d98752414747d262c542200f807539ab Signed-off-by: Matthew Khouzam Signed-off-by: Jean-Christian Kouame Reviewed-on: https://git.eclipse.org/r/65597 Reviewed-by: Genevieve Bastien Tested-by: Genevieve Bastien Reviewed-by: Hudson CI --- diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallDensityViewer.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallDensityViewer.java index aeb1646625..2c8fd978f1 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallDensityViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallDensityViewer.java @@ -12,7 +12,7 @@ package org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.swt.widgets.Composite; import org.eclipse.tracecompass.analysis.os.linux.core.latency.SystemCallLatencyAnalysis; -import org.eclipse.tracecompass.analysis.timing.core.segmentstore.AbstractSegmentStoreAnalysisModule; +import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider; import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.density.AbstractSegmentStoreDensityViewer; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils; @@ -36,7 +36,7 @@ public class SystemCallDensityViewer extends AbstractSegmentStoreDensityViewer { } @Override - protected @Nullable AbstractSegmentStoreAnalysisModule getSegmentStoreAnalysisModule(ITmfTrace trace) { + protected @Nullable ISegmentStoreProvider getSegmentStoreProvider(ITmfTrace trace) { return TmfTraceUtils.getAnalysisModuleOfClass(trace, SystemCallLatencyAnalysis.class, SystemCallLatencyAnalysis.ID); } } diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyDensityView.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyDensityView.java index b69815f1c4..304d55c9f9 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyDensityView.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyDensityView.java @@ -40,8 +40,8 @@ public class SystemCallLatencyDensityView extends AbstractSegmentStoreDensityVie protected AbstractSegmentStoreTableViewer createSegmentStoreTableViewer(Composite parent) { return new SystemCallLatencyTableViewer(new TableViewer(parent, SWT.FULL_SELECTION | SWT.VIRTUAL)) { @Override - protected void createAnalysisColumns() { - super.createAnalysisColumns(); + protected void createProviderColumns() { + super.createProviderColumns(); Table t = (Table) getControl(); t.setColumnOrder(new int[] { 2, 3, 0, 1 }); } diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyScatterGraphViewer.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyScatterGraphViewer.java index de1a403678..793a06503d 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyScatterGraphViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyScatterGraphViewer.java @@ -16,7 +16,7 @@ package org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.swt.widgets.Composite; import org.eclipse.tracecompass.analysis.os.linux.core.latency.SystemCallLatencyAnalysis; -import org.eclipse.tracecompass.analysis.timing.core.segmentstore.AbstractSegmentStoreAnalysisModule; +import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider; import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.scatter.AbstractSegmentStoreScatterGraphViewer; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils; @@ -47,7 +47,7 @@ public class SystemCallLatencyScatterGraphViewer extends AbstractSegmentStoreSca } @Override - protected @Nullable AbstractSegmentStoreAnalysisModule getSegmentStoreAnalysisModule(ITmfTrace trace) { + protected @Nullable ISegmentStoreProvider getSegmentStoreProvider(ITmfTrace trace) { return TmfTraceUtils.getAnalysisModuleOfClass(trace, SystemCallLatencyAnalysis.class, SystemCallLatencyAnalysis.ID); } } \ No newline at end of file diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyTableViewer.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyTableViewer.java index c1d28525de..0945369d72 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyTableViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyTableViewer.java @@ -15,7 +15,7 @@ package org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.tracecompass.analysis.os.linux.core.latency.SystemCallLatencyAnalysis; -import org.eclipse.tracecompass.analysis.timing.core.segmentstore.AbstractSegmentStoreAnalysisModule; +import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider; import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table.AbstractSegmentStoreTableViewer; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils; @@ -46,7 +46,7 @@ public class SystemCallLatencyTableViewer extends AbstractSegmentStoreTableViewe // ------------------------------------------------------------------------ @Override - protected @Nullable AbstractSegmentStoreAnalysisModule getSegmentStoreAnalysisModule(ITmfTrace trace) { + protected @Nullable ISegmentStoreProvider getSegmentStoreProvider(ITmfTrace trace) { return TmfTraceUtils.getAnalysisModuleOfClass(trace, SystemCallLatencyAnalysis.class, SystemCallLatencyAnalysis.ID); } } diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java index 32930e3159..f5db4dde2f 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java @@ -17,7 +17,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; -import java.util.Collection; +import java.util.Collections; import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; @@ -35,8 +35,6 @@ import org.eclipse.tracecompass.tmf.core.segment.ISegmentAspect; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; -import com.google.common.collect.ImmutableList; - /** * Abstract analysis module to generate a segment store. It is a base class that * can be used as a shortcut by analysis who just need to build a single segment @@ -46,7 +44,7 @@ import com.google.common.collect.ImmutableList; * @since 2.0 * */ -public abstract class AbstractSegmentStoreAnalysisModule extends TmfAbstractAnalysisModule { +public abstract class AbstractSegmentStoreAnalysisModule extends TmfAbstractAnalysisModule implements ISegmentStoreProvider { private final ListenerList fListeners = new ListenerList(ListenerList.IDENTITY); @@ -54,22 +52,12 @@ public abstract class AbstractSegmentStoreAnalysisModule extends TmfAbstractAnal private @Nullable ITmfEventRequest fOngoingRequest = null; - /** - * Listener for the viewers - * - * @param listener - * listener for each type of viewer - */ + @Override public void addListener(IAnalysisProgressListener listener) { fListeners.add(listener); } - /** - * Removes a listener for the viewers - * - * @param listener - * listener for each type of viewer to remove - */ + @Override public void removeListener(IAnalysisProgressListener listener) { fListeners.remove(listener); } @@ -89,16 +77,9 @@ public abstract class AbstractSegmentStoreAnalysisModule extends TmfAbstractAnal return listeners; } - /** - * Return the pre-defined set of segment aspects exposed by this analysis. - * - * It should not be null, but could be empty. - * - * @return The segment aspects for this analysis - */ + @Override public Iterable getSegmentAspects() { - Collection coll = ImmutableList.of(); - return checkNotNull(coll); + return Collections.emptyList(); } /** @@ -132,11 +113,7 @@ public abstract class AbstractSegmentStoreAnalysisModule extends TmfAbstractAnal */ protected abstract Object[] readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException; - /** - * Returns the segment store built by this analysis - * - * @return The segment store - */ + @Override public @Nullable ISegmentStore getSegmentStore() { return fSegmentStore; } diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/IAnalysisProgressListener.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/IAnalysisProgressListener.java index ba1c0accae..aaa45cae9e 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/IAnalysisProgressListener.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/IAnalysisProgressListener.java @@ -20,14 +20,14 @@ import org.eclipse.tracecompass.segmentstore.core.ISegmentStore; public interface IAnalysisProgressListener { /** - * Called at the end of the analysis + * Called at the end of the segment store construction * - * @param activeAnalysis + * @param segmentProvider * analysis that is running * * @param data * segment store of the latency analysis */ - void onComplete(AbstractSegmentStoreAnalysisModule activeAnalysis, ISegmentStore data); + void onComplete(ISegmentStoreProvider segmentProvider, ISegmentStore data); } diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/ISegmentStoreProvider.java b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/ISegmentStoreProvider.java new file mode 100644 index 0000000000..fcc2ca30c7 --- /dev/null +++ b/analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/ISegmentStoreProvider.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2016 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 + *******************************************************************************/ + +package org.eclipse.tracecompass.analysis.timing.core.segmentstore; + +import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.tracecompass.segmentstore.core.ISegment; +import org.eclipse.tracecompass.segmentstore.core.ISegmentStore; +import org.eclipse.tracecompass.tmf.core.segment.ISegmentAspect; + +/** + * Segment store provider. Useful to populate views. + * + * @author Matthew Khouzam + * @since 2.0 + */ +public interface ISegmentStoreProvider { + + /** + * Add a listener for the viewers + * + * @param listener + * listener for each type of viewer + */ + void addListener(IAnalysisProgressListener listener); + + /** + * Remove listener for the viewers + * + * @param listener + * listener for each type of viewer + */ + void removeListener(IAnalysisProgressListener listener); + + /** + * Return the pre-defined set of segment aspects exposed by this analysis. + * + * It should not be null, but could be empty. + * + * @return The segment aspects for this analysis + */ + Iterable getSegmentAspects(); + + /** + * Returns the result in a from the analysis in a ISegmentStore + * + * @return Results from the analysis in a ISegmentStore + */ + @Nullable ISegmentStore getSegmentStore(); + +} \ No newline at end of file diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/density/AbstractSegmentStoreDensityViewer.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/density/AbstractSegmentStoreDensityViewer.java index f6e3b8c163..6f4fd1f01c 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/density/AbstractSegmentStoreDensityViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/density/AbstractSegmentStoreDensityViewer.java @@ -25,8 +25,8 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; -import org.eclipse.tracecompass.analysis.timing.core.segmentstore.AbstractSegmentStoreAnalysisModule; import org.eclipse.tracecompass.analysis.timing.core.segmentstore.IAnalysisProgressListener; +import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider; import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.SubSecondTimeWithUnitFormat; import org.eclipse.tracecompass.common.core.NonNullUtils; import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.density.MouseDragZoomProvider; @@ -35,6 +35,7 @@ import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.d import org.eclipse.tracecompass.segmentstore.core.ISegment; import org.eclipse.tracecompass.segmentstore.core.ISegmentStore; import org.eclipse.tracecompass.segmentstore.core.SegmentComparators; +import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; @@ -59,7 +60,7 @@ import com.google.common.collect.Iterators; import com.google.common.collect.Lists; /** - * Displays the segment store analysis data in a density chart. + * Displays the segment store provider data in a density chart. * * @author Matthew Khouzam * @author Marc-Andre Laperle @@ -77,7 +78,7 @@ public abstract class AbstractSegmentStoreDensityViewer extends TmfViewer { private @Nullable ITmfTrace fTrace; private @Nullable IAnalysisProgressListener fListener; - private @Nullable AbstractSegmentStoreAnalysisModule fAnalysisModule; + private @Nullable ISegmentStoreProvider fSegmentStoreProvider; private TmfTimeRange fCurrentTimeRange = TmfTimeRange.NULL_RANGE; private List fListeners; @@ -107,13 +108,13 @@ public abstract class AbstractSegmentStoreDensityViewer extends TmfViewer { } /** - * Returns the segment store analysis module + * Returns the segment store provider * * @param trace * The trace to consider - * @return the analysis module + * @return the */ - protected @Nullable abstract AbstractSegmentStoreAnalysisModule getSegmentStoreAnalysisModule(ITmfTrace trace); + protected @Nullable abstract ISegmentStoreProvider getSegmentStoreProvider(ITmfTrace trace); @Nullable private static ITmfTrace getTrace() { @@ -206,11 +207,11 @@ public abstract class AbstractSegmentStoreDensityViewer extends TmfViewer { } private @Nullable List computeData(final TmfTimeRange timeRange, final Range durationRange) { - final AbstractSegmentStoreAnalysisModule analysisModule = fAnalysisModule; - if (analysisModule == null) { + final ISegmentStoreProvider segmentProvider = fSegmentStoreProvider; + if (segmentProvider == null) { return null; } - final ISegmentStore segStore = analysisModule.getSegmentStore(); + final ISegmentStore segStore = segmentProvider.getSegmentStore(); if (segStore == null) { return null; } @@ -255,7 +256,7 @@ public abstract class AbstractSegmentStoreDensityViewer extends TmfViewer { if (trace == null) { return; } - fAnalysisModule = getSegmentStoreAnalysisModule(trace); + fSegmentStoreProvider = getSegmentStoreProvider(trace); fCurrentTimeRange = NonNullUtils.checkNotNull(signal.getCurrentRange()); updateWithRange(fCurrentTimeRange); } @@ -271,8 +272,8 @@ public abstract class AbstractSegmentStoreDensityViewer extends TmfViewer { @Override public void dispose() { - if (fAnalysisModule != null && fListener != null) { - fAnalysisModule.removeListener(fListener); + if (fSegmentStoreProvider != null && fListener != null) { + fSegmentStoreProvider.removeListener(fListener); } fDragZoomProvider.deregister(); fTooltipProvider.deregister(); @@ -338,12 +339,14 @@ public abstract class AbstractSegmentStoreDensityViewer extends TmfViewer { fCurrentTimeRange = windowRange; if (trace != null) { - fAnalysisModule = getSegmentStoreAnalysisModule(trace); - final AbstractSegmentStoreAnalysisModule module = fAnalysisModule; - if (module != null) { - fListener = (activeAnalysis, data) -> updateWithRange(windowRange); - module.addListener(fListener); - module.schedule(); + fSegmentStoreProvider = getSegmentStoreProvider(trace); + final ISegmentStoreProvider provider = fSegmentStoreProvider; + if (provider != null) { + fListener = (segmentProvider, data) -> updateWithRange(windowRange); + provider.addListener(fListener); + if( provider instanceof IAnalysisModule) { + ((IAnalysisModule) provider).schedule(); + } } } zoom(new Range(0, Long.MAX_VALUE)); diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/scatter/AbstractSegmentStoreScatterGraphViewer.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/scatter/AbstractSegmentStoreScatterGraphViewer.java index 98f4c0c572..015140f0b0 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/scatter/AbstractSegmentStoreScatterGraphViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/scatter/AbstractSegmentStoreScatterGraphViewer.java @@ -28,8 +28,8 @@ import org.eclipse.jdt.annotation.Nullable; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; -import org.eclipse.tracecompass.analysis.timing.core.segmentstore.AbstractSegmentStoreAnalysisModule; import org.eclipse.tracecompass.analysis.timing.core.segmentstore.IAnalysisProgressListener; +import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider; import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.SubSecondTimeWithUnitFormat; import org.eclipse.tracecompass.common.core.NonNullUtils; import org.eclipse.tracecompass.internal.analysis.timing.ui.Activator; @@ -38,6 +38,7 @@ import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.s import org.eclipse.tracecompass.segmentstore.core.ISegment; import org.eclipse.tracecompass.segmentstore.core.ISegmentStore; import org.eclipse.tracecompass.segmentstore.core.SegmentComparators; +import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal; @@ -62,7 +63,7 @@ import org.swtchart.LineStyle; import org.swtchart.Range; /** - * Displays the segment store analysis data in a scatter graph + * Displays the segment store provider data in a scatter graph * * @author France Lapointe Nguyen * @author Matthew Khouzam - reduced memory usage @@ -88,20 +89,20 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Monitor is null"); //$NON-NLS-1$ } - AbstractSegmentStoreAnalysisModule module = getAnalysisModule(); + ISegmentStoreProvider segmentProvider = getSegmentProvider(); final long startTimeInNanos = fCurrentRange.getStartTime().toNanos(); final long endTimeInNanos = fCurrentRange.getEndTime().toNanos(); - if (module == null) { + if (segmentProvider == null) { setWindowRange(startTimeInNanos, endTimeInNanos); redraw(statusMonitor, startTimeInNanos, startTimeInNanos, Collections.EMPTY_LIST); - return new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Analysis module not available"); //$NON-NLS-1$ + return new Status(IStatus.WARNING, Activator.PLUGIN_ID, "segment provider not available"); //$NON-NLS-1$ } - final ISegmentStore segStore = module.getSegmentStore(); + final ISegmentStore segStore = segmentProvider.getSegmentStore(); if (segStore == null) { setWindowRange(startTimeInNanos, endTimeInNanos); redraw(statusMonitor, startTimeInNanos, startTimeInNanos, Collections.EMPTY_LIST); - return new Status(IStatus.INFO, Activator.PLUGIN_ID, "Analysis module does not have results"); //$NON-NLS-1$ + return new Status(IStatus.INFO, Activator.PLUGIN_ID, "Segment provider does not have segments"); //$NON-NLS-1$ } final long startTime = fCurrentRange.getStartTime().getValue(); @@ -191,16 +192,16 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL // ------------------------------------------------------------------------ /** - * Listener to update the model with the semgent store analysis results - * once the analysis is fully completed + * Listener to update the model with the segment store provider results once + * its segment store is fully completed */ - private final class AnalysisProgressListener implements IAnalysisProgressListener { + private final class SegmentStoreProviderProgressListener implements IAnalysisProgressListener { @Override - public void onComplete(AbstractSegmentStoreAnalysisModule activeAnalysis, ISegmentStore results) { + public void onComplete(ISegmentStoreProvider segmentProvider, ISegmentStore segmentStore) { // Only update the model if trace that was analyzed is active trace - if (activeAnalysis.equals(getAnalysisModule())) { - updateModel(results); + if (segmentProvider.equals(getSegmentProvider())) { + updateModel(segmentStore); updateRange(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange()); } } @@ -215,14 +216,14 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL private Collection fDisplayData = Collections.EMPTY_LIST; /** - * Analysis completion listener + * Provider completion listener */ - private AnalysisProgressListener fListener; + private SegmentStoreProviderProgressListener fListener; /** - * Current analysis module + * Current segment provider */ - private @Nullable AbstractSegmentStoreAnalysisModule fAnalysisModule; + private @Nullable ISegmentStoreProvider fSegmentProvider; private @Nullable Job fCompactingJob; @@ -245,19 +246,19 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL public AbstractSegmentStoreScatterGraphViewer(Composite parent, String title, String xLabel, String yLabel) { super(parent, title, xLabel, yLabel); setTooltipProvider(new SegmentStoreScatterGraphTooltipProvider(this)); - fListener = new AnalysisProgressListener(); + fListener = new SegmentStoreProviderProgressListener(); ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace(); - initializeModule(trace); + initializeProvider(trace); getSwtChart().getLegend().setVisible(false); getSwtChart().getAxisSet().getYAxis(0).getTick().setFormat(FORMAT); } - private final void initializeModule(@Nullable ITmfTrace trace) { + private final void initializeProvider(@Nullable ITmfTrace trace) { if (trace != null) { - final AbstractSegmentStoreAnalysisModule analysisModuleOfClass = getSegmentStoreAnalysisModule(trace); - if (analysisModuleOfClass != null) { - analysisModuleOfClass.addListener(fListener); - setData(analysisModuleOfClass); + final ISegmentStoreProvider segmentStoreProvider = getSegmentStoreProvider(trace); + if (segmentStoreProvider != null) { + segmentStoreProvider.addListener(fListener); + setData(segmentStoreProvider); updateRange(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange()); } } @@ -303,9 +304,9 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL @Override protected void initializeDataSource() { ITmfTrace trace = getTrace(); - initializeModule(trace); + initializeProvider(trace); if (trace != null) { - setData(getSegmentStoreAnalysisModule(trace)); + setData(getSegmentStoreProvider(trace)); } } @@ -388,39 +389,42 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL } /** - * Set the data into the viewer. Will update model is analysis is completed - * or run analysis if not completed + * Set the data into the viewer. If the provider is an analysis, it will + * update the model if the analysis is completed or run the analysis if not + * completed * - * @param analysis - * Segment store analysis module + * @param provider + * Segment store provider */ - public void setData(@Nullable AbstractSegmentStoreAnalysisModule analysis) { - if (analysis == null) { + public void setData(@Nullable ISegmentStoreProvider provider) { + if (provider == null) { updateModel(null); return; } - ISegmentStore segStore = analysis.getSegmentStore(); - // If results are not null, then analysis is completed and model can be - // updated + ISegmentStore segStore = provider.getSegmentStore(); + // If results are not null, then segment store is completed and model + // can be updated if (segStore != null) { updateModel(segStore); - setAnalysisModule(analysis); + setSegmentProvider(provider); return; } updateModel(null); - analysis.addListener(fListener); - analysis.schedule(); - setAnalysisModule(analysis); + provider.addListener(fListener); + if (provider instanceof IAnalysisModule) { + ((IAnalysisModule) provider).schedule(); + } + setSegmentProvider(provider); } /** - * Returns the segment store analysis module + * Returns the segment store provider * * @param trace * The trace to consider - * @return the analysis module + * @return the segment store provider */ - protected @Nullable abstract AbstractSegmentStoreAnalysisModule getSegmentStoreAnalysisModule(ITmfTrace trace); + protected @Nullable abstract ISegmentStoreProvider getSegmentStoreProvider(ITmfTrace trace); // ------------------------------------------------------------------------ // Signal handlers @@ -444,7 +448,7 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL setWindowRange( timeRange.getStartTime().toNanos(), timeRange.getEndTime().toNanos()); - setData(getSegmentStoreAnalysisModule(trace)); + setData(getSegmentStoreProvider(trace)); updateRange(timeRange); } } @@ -464,12 +468,12 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL setTrace(trace); if (trace != null) { - final AbstractSegmentStoreAnalysisModule analysisModuleOfClass = getSegmentStoreAnalysisModule(trace); + final ISegmentStoreProvider segmentStoreProvider = getSegmentStoreProvider(trace); final TmfTimeRange timeRange = TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange(); setWindowRange( timeRange.getStartTime().toNanos(), timeRange.getEndTime().toNanos()); - setData(analysisModuleOfClass); + setData(segmentStoreProvider); } } @@ -495,9 +499,9 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL if (signal != null) { // Check if there is no more opened trace if (TmfTraceManager.getInstance().getActiveTrace() == null) { - AbstractSegmentStoreAnalysisModule analysis = getAnalysisModule(); - if (analysis != null) { - analysis.removeListener(fListener); + ISegmentStoreProvider provider = getSegmentProvider(); + if (provider != null) { + provider.removeListener(fListener); } clearContent(); } @@ -524,11 +528,11 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL } } - private @Nullable AbstractSegmentStoreAnalysisModule getAnalysisModule() { - return fAnalysisModule; + private @Nullable ISegmentStoreProvider getSegmentProvider() { + return fSegmentProvider; } - private void setAnalysisModule(AbstractSegmentStoreAnalysisModule analysisModule) { - fAnalysisModule = analysisModule; + private void setSegmentProvider(ISegmentStoreProvider provider) { + fSegmentProvider = provider; } } \ No newline at end of file diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableView.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableView.java index f399d57672..4a1460d198 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableView.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableView.java @@ -100,7 +100,7 @@ public abstract class AbstractSegmentStoreTableView extends TmfView { */ private void setInitialData() { if (fSegmentStoreViewer != null) { - fSegmentStoreViewer.setData(fSegmentStoreViewer.getAnalysisModule()); + fSegmentStoreViewer.setData(fSegmentStoreViewer.getSegmentProvider()); } } } diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableViewer.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableViewer.java index 5bae6d2443..60fb8fb22c 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableViewer.java @@ -28,14 +28,15 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.tracecompass.analysis.timing.core.segmentstore.AbstractSegmentStoreAnalysisModule; import org.eclipse.tracecompass.analysis.timing.core.segmentstore.IAnalysisProgressListener; +import org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider; import org.eclipse.tracecompass.common.core.NonNullUtils; import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.table.Messages; import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.table.SegmentStoreContentProvider; import org.eclipse.tracecompass.segmentstore.core.ISegment; import org.eclipse.tracecompass.segmentstore.core.ISegmentStore; import org.eclipse.tracecompass.segmentstore.core.SegmentComparators; +import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule; import org.eclipse.tracecompass.tmf.core.segment.ISegmentAspect; import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; @@ -51,7 +52,7 @@ import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; import org.eclipse.tracecompass.tmf.ui.viewers.table.TmfSimpleTableViewer; /** - * Displays the segment store analysis data in a column table + * Displays the segment store provider data in a column table * * @author France Lapointe Nguyen * @since 2.0 @@ -64,7 +65,7 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView /** * Abstract class for the column label provider for the segment store - * analysis table viewer + * provider table viewer */ private abstract class SegmentStoreTableColumnLabelProvider extends ColumnLabelProvider { @@ -81,15 +82,15 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView } /** - * Listener to update the model with the segment store analysis results - * once the analysis is fully completed + * Listener to update the model with the segment store provider results once + * its store is fully completed */ - private final class AnalysisProgressListener implements IAnalysisProgressListener { + private final class SegmentStoreProviderProgressListener implements IAnalysisProgressListener { @Override - public void onComplete(AbstractSegmentStoreAnalysisModule activeAnalysis, ISegmentStore data) { - // Check if the active trace was changed while the analysis was - // running - if (activeAnalysis.equals(fAnalysisModule)) { + public void onComplete(ISegmentStoreProvider activeProvider, ISegmentStore data) { + // Check if the active trace was changed while the provider was + // building its segment store + if (activeProvider.equals(fSegmentProvider)) { updateModel(data); } } @@ -110,14 +111,14 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView } /** - * Current segment store analysis module + * Current segment store provider */ - private @Nullable AbstractSegmentStoreAnalysisModule fAnalysisModule = null; + private @Nullable ISegmentStoreProvider fSegmentProvider = null; /** - * Analysis progress listener + * provider progress listener */ - private AnalysisProgressListener fListener; + private SegmentStoreProviderProgressListener fListener; /** * Flag to create columns once @@ -140,12 +141,12 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView getTableViewer().setContentProvider(new SegmentStoreContentProvider()); ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace(); if (trace != null) { - fAnalysisModule = getSegmentStoreAnalysisModule(trace); + fSegmentProvider = getSegmentStoreProvider(trace); } createColumns(); getTableViewer().getTable().addSelectionListener(new TableSelectionListener()); addPackListener(); - fListener = new AnalysisProgressListener(); + fListener = new SegmentStoreProviderProgressListener(); } // ------------------------------------------------------------------------ @@ -179,20 +180,20 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView } /** - * Create columns specific to the analysis + * Create columns specific to the provider */ - protected void createAnalysisColumns() { + protected void createProviderColumns() { if (!fColumnsCreated) { - AbstractSegmentStoreAnalysisModule analysis = getAnalysisModule(); - if (analysis != null) { - for (final ISegmentAspect aspect : analysis.getSegmentAspects()) { + ISegmentStoreProvider provider = getSegmentProvider(); + if (provider != null) { + for (final ISegmentAspect aspect : provider.getSegmentAspects()) { createColumn(aspect.getName(), new SegmentStoreTableColumnLabelProvider() { @Override public String getTextForSegment(ISegment input) { return NonNullUtils.nullToEmptyString(aspect.resolve(input)); } }, - aspect.getComparator()); + aspect.getComparator()); } } fColumnsCreated = true; @@ -230,42 +231,46 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView } /** - * Set the data into the viewer. Will update model is analysis is completed - * or run analysis if not completed + * Set the data into the viewer. It will update the model. If the provider + * is an analysis, the analysis will be scheduled. * - * @param analysis - * segment store analysis module + * @param provider + * segment store provider */ - public void setData(@Nullable AbstractSegmentStoreAnalysisModule analysis) { - // Set the current segment store analysis module - fAnalysisModule = analysis; - if (analysis == null) { + public void setData(@Nullable ISegmentStoreProvider provider) { + // Set the current segment store provider + fSegmentProvider = provider; + if (provider == null) { updateModel(null); return; } - createAnalysisColumns(); + createProviderColumns(); - ISegmentStore segStore = analysis.getSegmentStore(); - // If results are not null, then analysis is completed and model can be - // updated + ISegmentStore segStore = provider.getSegmentStore(); + // If results are not null, then the segment of the provider is ready + // and model can be updated if (segStore != null) { updateModel(segStore); return; } - // If results are null, then add completion listener and run analysis + // If results are null, then add completion listener and if the provider + // is an analysis, run the analysis updateModel(null); - analysis.addListener(fListener); - analysis.schedule(); + provider.addListener(fListener); + if (provider instanceof IAnalysisModule) { + ((IAnalysisModule) provider).schedule(); + } } /** - * Returns the segment store analysis module + * Returns the segment store provider + * * @param trace * The trace to consider - * @return the segment store analysis module + * @return the segment store provider */ - protected @Nullable abstract AbstractSegmentStoreAnalysisModule getSegmentStoreAnalysisModule(ITmfTrace trace); + protected @Nullable abstract ISegmentStoreProvider getSegmentStoreProvider(ITmfTrace trace); @Override protected void appendToTablePopupMenu(IMenuManager manager, IStructuredSelection sel) { @@ -295,12 +300,12 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView // ------------------------------------------------------------------------ /** - * Get current segment store analysis module + * Get current segment store provider * - * @return current segment store analysis module + * @return current segment store provider */ - public @Nullable AbstractSegmentStoreAnalysisModule getAnalysisModule() { - return fAnalysisModule; + public @Nullable ISegmentStoreProvider getSegmentProvider() { + return fSegmentProvider; } // ------------------------------------------------------------------------ @@ -318,7 +323,7 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView public void traceSelected(TmfTraceSelectedSignal signal) { ITmfTrace trace = signal.getTrace(); if (trace != null) { - setData(getSegmentStoreAnalysisModule(trace)); + setData(getSegmentStoreProvider(trace)); } } @@ -333,7 +338,7 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView public void traceOpened(TmfTraceOpenedSignal signal) { ITmfTrace trace = signal.getTrace(); if (trace != null) { - setData(getSegmentStoreAnalysisModule(trace)); + setData(getSegmentStoreProvider(trace)); } } @@ -353,9 +358,9 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView refresh(); } - AbstractSegmentStoreAnalysisModule analysis = getAnalysisModule(); - if ((analysis != null)) { - analysis.removeListener(fListener); + ISegmentStoreProvider provider = getSegmentProvider(); + if ((provider != null)) { + provider.removeListener(fListener); } } } diff --git a/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/treemap/TreeMapStore.java b/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/treemap/TreeMapStore.java index 590f25057e..b358045beb 100644 --- a/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/treemap/TreeMapStore.java +++ b/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/treemap/TreeMapStore.java @@ -150,7 +150,6 @@ public class TreeMapStore<@NonNull E extends ISegment> implements ISegmentStore< } } - @Override public boolean containsAll(@Nullable Collection c) { fLock.readLock().lock(); @@ -218,7 +217,14 @@ public class TreeMapStore<@NonNull E extends ISegment> implements ISegmentStore< @Override public void clear() { - throw new UnsupportedOperationException(); + fLock.writeLock().lock(); + try { + fSize = 0; + fEndTimesIndex.clear(); + fStartTimesIndex.clear(); + } finally { + fLock.writeLock().unlock(); + } } // ------------------------------------------------------------------------