analysis: introduce ISegmentStoreProvider
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Sat, 30 Jan 2016 02:51:58 +0000 (21:51 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 4 Mar 2016 21:13:52 +0000 (16:13 -0500)
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 <matthew.khouzam@ericsson.com>
Signed-off-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/65597
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Hudson CI
12 files changed:
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallDensityViewer.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyDensityView.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyScatterGraphViewer.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyTableViewer.java
analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/AbstractSegmentStoreAnalysisModule.java
analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/IAnalysisProgressListener.java
analysis/org.eclipse.tracecompass.analysis.timing.core/src/org/eclipse/tracecompass/analysis/timing/core/segmentstore/ISegmentStoreProvider.java [new file with mode: 0644]
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/density/AbstractSegmentStoreDensityViewer.java
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/scatter/AbstractSegmentStoreScatterGraphViewer.java
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableView.java
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/AbstractSegmentStoreTableViewer.java
statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/treemap/TreeMapStore.java

index aeb16466256ba9d598ce6cf8ba50adbcebd2b18b..2c8fd978f1972b0a435a5c392ada066bbf430167 100644 (file)
@@ -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);
     }
 }
index b69815f1c4d2bc816679527e14d100b1407b83f5..304d55c9f99097d68ee657d7fe244c508d609c9f 100644 (file)
@@ -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 });
             }
index de1a4036786df79833a96eff1e6b31e9607327bc..793a06503d5be177f8dd7dcd2d1fa02d891ffe6b 100644 (file)
@@ -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
index c1d28525de24ce9994e57490cb0203a5056b0c1a..0945369d725c320eadee679bda6ee59be007a127 100644 (file)
@@ -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);
     }
 }
index 32930e3159a644f2a1d31a37bf83668b34a1799c..f5db4dde2fc00d245305c0b88c733a834de0cc28 100644 (file)
@@ -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<ISegmentAspect> getSegmentAspects() {
-        Collection<ISegmentAspect> 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<ISegment> getSegmentStore() {
         return fSegmentStore;
     }
index ba1c0accae0dc3e3025c9d303b909b79294d045c..aaa45cae9e17a42a5282eb7ba8cbd171ebff3748 100644 (file)
@@ -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<ISegment> data);
+    void onComplete(ISegmentStoreProvider segmentProvider, ISegmentStore<ISegment> 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 (file)
index 0000000..fcc2ca3
--- /dev/null
@@ -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<ISegmentAspect> getSegmentAspects();
+
+    /**
+     * Returns the result in a from the analysis in a ISegmentStore
+     *
+     * @return Results from the analysis in a ISegmentStore
+     */
+    @Nullable ISegmentStore<ISegment> getSegmentStore();
+
+}
\ No newline at end of file
index f6e3b8c16333e0982ced204320665ca608c1b294..6f4fd1f01cd94261acafefc7de55313a80981666 100644 (file)
@@ -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<ISegmentStoreDensityViewerDataListener> 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<ISegment> 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<ISegment> segStore = analysisModule.getSegmentStore();
+        final ISegmentStore<ISegment> 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));
index 98f4c0c5726ec415b57c874a80b4ec7e46b43de3..015140f0b046c57f8cf2c418c11bdbe3fe0752c6 100644 (file)
@@ -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<ISegment> segStore = module.getSegmentStore();
+            final ISegmentStore<ISegment> 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<ISegment> results) {
+        public void onComplete(ISegmentStoreProvider segmentProvider, ISegmentStore<ISegment> 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<ISegment> 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<ISegment> segStore = analysis.getSegmentStore();
-        // If results are not null, then analysis is completed and model can be
-        // updated
+        ISegmentStore<ISegment> 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
index f399d57672710e84c5c9f55a8fc4bbece04bd876..4a1460d198ab4d897208d5e2c61192f31a4d9163 100644 (file)
@@ -100,7 +100,7 @@ public abstract class AbstractSegmentStoreTableView extends TmfView {
      */
     private void setInitialData() {
         if (fSegmentStoreViewer != null) {
-            fSegmentStoreViewer.setData(fSegmentStoreViewer.getAnalysisModule());
+            fSegmentStoreViewer.setData(fSegmentStoreViewer.getSegmentProvider());
         }
     }
 }
index 5bae6d2443b708c3c29b7945d6bf449a13a0bbc1..60fb8fb22c28131b4a472d43cbc1752d1e750656 100644 (file)
@@ -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<ISegment> data) {
-            // Check if the active trace was changed while the analysis was
-            // running
-            if (activeAnalysis.equals(fAnalysisModule)) {
+        public void onComplete(ISegmentStoreProvider activeProvider, ISegmentStore<ISegment> 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<ISegment> segStore = analysis.getSegmentStore();
-        // If results are not null, then analysis is completed and model can be
-        // updated
+        ISegmentStore<ISegment> 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);
             }
         }
     }
index 590f25057e0c074c1cfe722ccd5f7804372cd50a..b358045bebd6ea4442c97a34e5561f50eae599fc 100644 (file)
@@ -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();
+        }
     }
 
     // ------------------------------------------------------------------------
This page took 0.04146 seconds and 5 git commands to generate.